-
Notifications
You must be signed in to change notification settings - Fork 4k
importer: add ImportStartWallTime table descriptor field #85852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
craig
merged 2 commits into
cockroachdb:master
from
msbutler:butler-descriptor-import-start-time
Aug 13, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
106 changes: 106 additions & 0 deletions
106
pkg/ccl/backupccl/testdata/backup-restore/import-start-time
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Test that Import properly sets and removes the ImportStartTime from the table descriptor. | ||
| # The basic idea: | ||
| # For table with or without data: | ||
| ## -start and pause an import | ||
| ## -check that the ImportStartTime is set on the descriptor | ||
| ## -check that it's removed after cancellation / success | ||
|
|
||
| new-server name=s1 | ||
| ---- | ||
|
|
||
| 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'); | ||
| ---- | ||
|
|
||
|
|
||
| exec-sql | ||
| CREATE VIEW import_time (importStartTime) | ||
| AS WITH tbls AS ( | ||
| SELECT id, crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) AS orig FROM system.descriptor | ||
| ) | ||
| SELECT orig->'table'->'importStartWallTime' FROM tbls | ||
| INNER JOIN (SELECT id FROM system.namespace WHERE name='foo') AS sys | ||
| ON sys.id = tbls.id; | ||
| ---- | ||
|
|
||
| exec-sql | ||
| EXPORT INTO CSV 'nodelocal://0/export1/' FROM SELECT * FROM baz WHERE i = 1; | ||
| ---- | ||
|
|
||
| exec-sql | ||
| SET CLUSTER SETTING jobs.debug.pausepoints = 'import.after_ingest'; | ||
| ---- | ||
|
|
||
| import expect-pausepoint tag=a | ||
| IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export1/export*-n*.0.csv') | ||
| ---- | ||
| job paused at pausepoint | ||
|
|
||
|
|
||
| query-sql regex=^"\d. | ||
| SELECT * FROM import_time | ||
| ---- | ||
| true | ||
|
|
||
| # attempting another import on the table should fail, as there's already an in-progress import | ||
| # on the table. | ||
| exec-sql | ||
| IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export1/export*-n*.0.csv') | ||
| ---- | ||
| pq: relation "foo" is offline: importing | ||
|
|
||
| # Cancel the job so that the cleanup hook runs, and ensure the importStartTime is 0. | ||
| job cancel=a | ||
| ---- | ||
|
|
||
| query-sql | ||
| SELECT * FROM import_time | ||
| ---- | ||
| <nil> | ||
|
|
||
| # remove the pause setting, and try the import again and ensure it succeeds. | ||
| exec-sql | ||
| SET CLUSTER SETTING jobs.debug.pausepoints = ''; | ||
| ---- | ||
|
|
||
| exec-sql | ||
| IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export1/export*-n*.0.csv') | ||
| ---- | ||
|
|
||
| query-sql | ||
| SELECT * FROM import_time | ||
| ---- | ||
| <nil> | ||
|
|
||
|
|
||
| # ensure importing into an existing table also modifies the descriptor properly | ||
| exec-sql | ||
| EXPORT INTO CSV 'nodelocal://0/export2/' FROM SELECT * FROM baz WHERE i = 2; | ||
| ---- | ||
|
|
||
| exec-sql | ||
| SET CLUSTER SETTING jobs.debug.pausepoints = 'import.after_ingest'; | ||
| ---- | ||
|
|
||
| import expect-pausepoint tag=b | ||
| IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export2/export*-n*.0.csv') | ||
| ---- | ||
| job paused at pausepoint | ||
|
|
||
| query-sql regex=^"\d. | ||
| SELECT * FROM import_time | ||
| ---- | ||
| true | ||
|
|
||
| # Cancel the job so that the cleanup hook runs. | ||
| job cancel=b | ||
| ---- | ||
|
|
||
| query-sql | ||
| SELECT * FROM import_time | ||
| ---- | ||
| <nil> | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.