-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
importer: add ImportEpoch table descriptor field #85692
Closed
msbutler
wants to merge
2
commits into
cockroachdb:master
from
msbutler:butler-import-descriptor-epoch
Closed
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Test that Import INTO properly increments the importEpoch descriptor field only when the user runs | ||
# an IMPORT INTO on a non-empty table. | ||
|
||
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_epoch (epoch, type) | ||
AS WITH tbls AS ( | ||
SELECT id, crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) AS orig FROM system.descriptor | ||
) | ||
SELECT orig->'table'->'importEpoch', orig->'table'->'importTypeInProgress' FROM tbls WHERE id = '109'; | ||
---- | ||
|
||
exec-sql | ||
EXPORT INTO CSV 'nodelocal://0/export1/' FROM SELECT * FROM baz WHERE i = 1; | ||
---- | ||
|
||
exec-sql | ||
IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export1/export*-n*.0.csv') | ||
---- | ||
|
||
query-sql | ||
SELECT name, id FROM system.namespace WHERE name = 'foo'; | ||
---- | ||
foo 109 | ||
|
||
query-sql | ||
SELECT * FROM import_epoch | ||
---- | ||
1 <nil> | ||
|
||
exec-sql | ||
EXPORT INTO CSV 'nodelocal://0/export2/' FROM SELECT * FROM baz WHERE i = 2; | ||
---- | ||
|
||
exec-sql | ||
IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export2/export*-n*.0.csv') | ||
---- | ||
|
||
query-sql | ||
SELECT * FROM import_epoch | ||
---- | ||
2 <nil> | ||
|
||
exec-sql | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'import.after_ingest'; | ||
---- | ||
|
||
exec-sql | ||
EXPORT INTO CSV 'nodelocal://0/export3/' FROM SELECT * FROM baz WHERE i = 3; | ||
---- | ||
|
||
# ensure the ImportEpoch increments before planning and does not rollback after the IMPORT INTO | ||
# job gets cancelled | ||
import expect-pausepoint tag=a | ||
IMPORT INTO foo (i,s) CSV DATA ('nodelocal://0/export3/export*-n*.0.csv') | ||
---- | ||
job paused at pausepoint | ||
|
||
query-sql | ||
SELECT * FROM import_epoch | ||
---- | ||
3 "IMPORT_INTO_NON_EMPTY" | ||
|
||
# Cancel the job so that the cleanup hook runs. | ||
job cancel=a | ||
---- | ||
|
||
query-sql | ||
SELECT * FROM import_epoch | ||
---- | ||
3 <nil> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -1180,7 +1180,23 @@ message TableDescriptor { | |
// this table, in which case the global setting is used. | ||
optional bool forecast_stats = 52 [(gogoproto.nullable) = true, (gogoproto.customname) = "ForecastStats"]; | ||
|
||
// Next ID: 54 | ||
// ImportIntoEpoch is the count of IMPORT INTO jobs that have been attempted on this | ||
// table once it __already had data__. The ImportEpoch can include an in progress import, as the | ||
// field gets incremented while preparing the table for ingestion. | ||
optional uint32 import_epoch = 54 [(gogoproto.nullable) = false, (gogoproto.customname) = "ImportEpoch"]; | ||
|
||
// ImportType indicates the kind of import currently occurring on the table. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could explain the differences. Why is |
||
enum ImportType { | ||
NO_IMPORT = 0; | ||
IMPORT = 1; | ||
IMPORT_INTO_EMPTY = 2; | ||
IMPORT_INTO_NON_EMPTY = 3; | ||
} | ||
|
||
// ImportTypeInProgress describes the type of in-progress import, if any. | ||
optional ImportType import_type_in_progress = 55 [(gogoproto.nullable) = false, (gogoproto.customname) = "ImportTypeInProgress"]; | ||
|
||
// Next ID: 56 | ||
} | ||
|
||
// SurvivalGoal is the survival goal for a database. | ||
|
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.