-
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
schemachanger: defer catalog writes pre-commit #95330
Conversation
fff349b
to
686240a
Compare
Previously, it was impossible to execute EXPLAIN (DDL) COMMENT ON... This commit fixes this. Release note (bug fix): EXPLAIN (DDL) COMMENT ON is now possible.
This commit fixes a bug with this function which only becomes apparent when not using bazel. This only impacts testing with GoLand. Release note: None
In some cases, we define a set of almost-identical rules with the same name, purposefully. The name is what is used by the data-driven test output to sort the rule definitions, because these otherwise appear in the order that the init() functions were called, which is undefined. Sorting by name reduced the instability of the data-driven test when adding or removing init() blocks containing rule definitions, but did not altogether remove it. This commit should help further remove it by using a stable sort. In this way, the test output should be stable assuming that rule names are not re-used across init() blocks. Release note: None
This commit adds an underscore in the generated tests' name where there previously was one missing. Release note: None
This operation is no longer required. Release note: None
This commit fixes a bug where comments weren't handled correctly by the test state. This wasn't noticeable because the code wasn't actually exercised anywhere. This commit also fixes this. Release note: None
Previously, in the declarative schema changer, each mutation stage would be executed by visiting each of the stage's mutation ops to collect the mutation state, followed by applying the mutations eagerly. This commit defers the running of kv.Batch containing the catalog mutations to the pre-commit phase. This change doesn't functionally change anything but paves the way for undoing all pending catalog mutations and re-planning the schema changes at pre-commit time. Informs cockroachdb#88294. Release note: None
686240a
to
953dff4
Compare
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.
This could have been a few commits or PRs. I think the comment changes are welcome but maybe need some attention regarding their revertibility. The testutils change I don't get. In general, it looks good.
commit sql txn DelRange /Table/24/1/1/109 | ||
commit sql txn DelRange /Table/24/1/2/109 | ||
commit sql txn DelRange /Table/24/1/3/109 | ||
commit sql txn DelRange /Table/24/1/5/109 |
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.
Do you have a clear understanding as to why this went away?
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.
Yes, 9b8eb53 removes the RemoveAllTableComments
op which was completely redundant and which generated those DelRange
s.
@@ -51,7 +51,7 @@ sctest_gen( | |||
ccl = True, | |||
new_cluster_func = "newCluster", | |||
package = "schemachangerccl", | |||
suffix = "base", | |||
suffix = "_base", |
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.
Thank you
│ ├── • LogEvent | ||
│ │ Element: | ||
│ │ TableComment: | ||
│ │ comment: t has a comment | ||
│ │ tableId: 107 | ||
│ │ EventBase: | ||
│ │ Authorization: | ||
│ │ UserName: root | ||
│ │ Statement: DROP TABLE ‹db›.‹sc›.‹t› | ||
│ │ StatementTag: DROP TABLE | ||
│ │ TargetMetadata: | ||
│ │ SourceElementID: 1 | ||
│ │ SubWorkID: 1 | ||
│ │ TargetStatus: 1 |
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.
I can't decide whether this is a good thing to show. It's fine for now but we might end up generating a lot of events when dropping tables.
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.
I'm working on this. The event logs are a bit of a nightmare to work with in the declarative schema changer. We should just roll out a new kind of event message.
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.
In any case, the event for comments exists, for better or for worse. Removing logging of comment events is out of scope of this PR.
├── • UpsertColumnComment | ||
│ ColumnID: 2 | ||
│ Comment: j has a comment | ||
│ PGAttributeNum: 2 | ||
│ TableID: 104 | ||
│ | ||
├── • LogEvent | ||
│ Element: | ||
│ ColumnComment: | ||
│ columnId: 2 | ||
│ comment: j has a comment | ||
│ pgAttributeNum: 2 | ||
│ tableId: 104 | ||
│ EventBase: | ||
│ Authorization: | ||
│ UserName: root | ||
│ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› | ||
│ StatementTag: ALTER TABLE | ||
│ TargetMetadata: | ||
│ SourceElementID: 1 | ||
│ SubWorkID: 1 | ||
│ TargetStatus: 2 |
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.
I wonder about this. Perhaps we want to not remove the comment until we hit the non-revertible stage.
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.
I'm working towards that, but this test output changed only because I added a comment, not because I changed any behaviour, so eager comment removal is already a thing right now.
@@ -64,7 +65,18 @@ func RewritableDataPath(t testing.TB, relative ...string) string { | |||
if !ok { | |||
t.Fatal("unable to get caller information") | |||
} | |||
cockroachWorkspace := filepath.Dir(filepath.Dir(filepath.Dir(thisFilePath))) | |||
cockroachWorkspace := thisFilePath |
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.
what is this about? isn't testutils/datapathutils/data_path.go
always at a fixed depth from the workspace dir?
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.
It got broken when RewritableDataPath
got moved to a new datapathutils
package with a different fixed depth than the old fixed depth. I guess nobody noticed until now.
Closed in favour of #95467 which just has small fixes. |
Previously, in the declarative schema changer, each mutation stage would
be executed by visiting each of the stage's mutation ops to collect the
mutation state, followed by applying the mutations eagerly.
This commit defers the running of kv.Batch containing the catalog
mutations to the pre-commit phase. This change doesn't functionally
change anything but paves the way for undoing all pending catalog
mutations and re-planning the schema changes at pre-commit time.
Informs #88294.
Release note: None