-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql,backupccl: create IMPORT ROLLBACK job in online restore
Tables that are offline and have a non-zero ImportEpoch are now restored to their offline state and an IMPORT ROLLBACK job is synthesized. The IMPORT ROLLBACK job uses an epoch-based predicate delete to rollback the table and bring it back online. Epic: none Release note: None
- Loading branch information
1 parent
f5cd323
commit 1615358
Showing
10 changed files
with
295 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 41 additions & 10 deletions
51
pkg/ccl/backupccl/testdata/backup-restore/online-restore-in-progress-imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,66 @@ | ||
# This test ensures that online restore failes when restoring tables | ||
# undergoing an in progress import | ||
# This test ensures that online restore generates an IMPORT ROLLBACK | ||
# job. | ||
|
||
reset test-nodelocal | ||
---- | ||
|
||
new-cluster name=s1 disable-tenant | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE d; | ||
USE d; | ||
CREATE TABLE foo (i INT PRIMARY KEY, s STRING); | ||
CREATE TABLE baz (i INT PRIMARY KEY, s STRING); | ||
INSERT INTO baz VALUES (1, 'x'),(2,'y'),(3,'z'); | ||
INSERT INTO foo VALUES (4, 'a'); | ||
---- | ||
|
||
exec-sql | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'import.after_ingest'; | ||
EXPORT INTO CSV 'nodelocal://1/export1/' FROM SELECT * FROM baz; | ||
---- | ||
NOTICE: EXPORT is not the recommended way to move data out of CockroachDB and may be deprecated in the future. Please consider exporting data with changefeeds instead: https://www.cockroachlabs.com/docs/stable/export-data-with-changefeeds | ||
|
||
|
||
|
||
exec-sql | ||
SET CLUSTER SETTING bulkio.backup.elide_common_prefix.enabled = false; | ||
---- | ||
|
||
exec-sql | ||
SET CLUSTER SETTING bulkio.import.write_import_epoch.enabled = true; | ||
---- | ||
|
||
exec-sql | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'import.after_ingest'; | ||
---- | ||
|
||
# Pause the import job, in order to back up the importing data. | ||
import expect-pausepoint tag=a | ||
IMPORT INTO data.bank CSV DATA ('workload:///csv/bank/bank?rows=100&version=1.0.0') | ||
IMPORT INTO foo (i,s) CSV DATA ('nodelocal://1/export1/export*-n*.0.csv') | ||
---- | ||
job paused at pausepoint | ||
|
||
|
||
exec-sql | ||
BACKUP INTO 'nodelocal://1/cluster/'; | ||
---- | ||
|
||
|
||
new-cluster name=s2 share-io-dir=s1 allow-implicit-access disable-tenant | ||
new-cluster name=s2 allow-implicit-access disable-tenant | ||
---- | ||
|
||
exec-sql | ||
RESTORE DATABASE d FROM LATEST IN 'nodelocal://1/cluster/' WITH EXPERIMENTAL DEFERRED COPY; | ||
---- | ||
|
||
exec-sql | ||
RESTORE DATABASE data FROM LATEST IN 'nodelocal://1/cluster/' with EXPERIMENTAL DEFERRED COPY; | ||
SHOW JOB WHEN COMPLETE (SELECT id FROM system.jobs WHERE job_type = 'IMPORT ROLLBACK') | ||
---- | ||
|
||
query-sql | ||
SELECT description, status FROM [SHOW JOBS (SELECT id FROM system.jobs WHERE job_type = 'IMPORT ROLLBACK')] | ||
---- | ||
ROLLBACK IMPORT INTO foo succeeded | ||
|
||
query-sql | ||
SELECT count(1) FROM d.foo | ||
---- | ||
pq: table bank (id 106) in restoring backup has an in-progress import, but online restore cannot be run on a table with an in progress import | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.