sql: run schema changes after CREATE TABLE in txn#25410
sql: run schema changes after CREATE TABLE in txn#25410craig[bot] merged 1 commit intocockroachdb:masterfrom
Conversation
| DROP TABLE hood | ||
|
|
||
| statement count 3 | ||
| CREATE TABLE hood (item, quantity) AS VALUES ('cups', 10), ('plates', 30), ('forks', 15) |
There was a problem hiding this comment.
This data should be different from the first CREATE just so we can verify it's indeed the second CREATE that is being queried.
| CREATE TABLE hood (item, quantity) AS VALUES ('cups', 10), ('plates', 30), ('forks', 15) | ||
|
|
||
| query TI | ||
| SELECT * FROM hood |
There was a problem hiding this comment.
should have an ORDER BY here
| ALTER TABLE shop RENAME TO ship | ||
|
|
||
| statement count 3 | ||
| CREATE TABLE shop (item, quantity) AS VALUES ('cups', 10), ('plates', 30), ('forks', 15) |
There was a problem hiding this comment.
same: change the data here
| CREATE TABLE shop (item, quantity) AS VALUES ('cups', 10), ('plates', 30), ('forks', 15) | ||
|
|
||
| query TI | ||
| SELECT * FROM shop |
There was a problem hiding this comment.
ORDER BY, ditto below
|
|
||
| statement ok | ||
| COMMIT | ||
|
|
There was a problem hiding this comment.
I would like to see a few more tests in the error case to make sure we handle those correctly:
- CREATE TABLE; add some data, add unique index that fails due to uniqueness violations
- CREATE TABLE; add computed column that fails due to an error during computation (like a divide by 0)
d849554 to
10638ef
Compare
|
Thanks for review this change. I've now boosted it up quite some bit with tests and in doing so uncovered some problems. It's now ready for review. Thanks! Review status: 0 of 7 files reviewed at latest revision, 5 unresolved discussions. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 138 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
I don't believe that's necessary right? Comments from Reviewable |
|
Review status: 0 of 7 files reviewed at latest revision, 5 unresolved discussions. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 135 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 159 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 177 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. Comments from Reviewable |
|
Review status: 0 of 7 files reviewed at latest revision, 5 unresolved discussions. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 177 at r2 (raw file): Previously, vivekmenezes wrote…
Done. Comments from Reviewable |
|
Review status: 0 of 7 files reviewed at latest revision, 5 unresolved discussions. pkg/sql/backfill.go, line 621 at r3 (raw file):
nit: this block can be removed pkg/sql/backfill.go, line 625 at r3 (raw file):
Why does this line need to be here? Can we just range over tableDesc.Mutations? I don't see how this loop would ever run more than once. pkg/sql/table.go, line 458 at r3 (raw file):
No need for this if block. Code is clearer without it. pkg/sql/table.go, line 511 at r3 (raw file):
Why this change? pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 138 at r2 (raw file): Previously, vivekmenezes wrote…
SQL can return data in any order if an ORDER BY is not specified. See #24223. Or you can use the rowsort flag in the logictest. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 235 at r3 (raw file):
You can run a Comments from Reviewable |
|
TFTR! Ready for another viewing. Thanks Review status: 0 of 7 files reviewed at latest revision, 10 unresolved discussions. pkg/sql/backfill.go, line 621 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/backfill.go, line 625 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/table.go, line 458 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
Good point. I didn't know a nil map was readable! pkg/sql/table.go, line 511 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
I've added a comment to explain the need to traverse both uncommitted databases and tables in the reverse order. This is tested i this PR. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 135 at r2 (raw file): Previously, vivekmenezes wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 138 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 159 at r2 (raw file): Previously, vivekmenezes wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 162 at r2 (raw file): Previously, mjibson (Matt Jibson) wrote…
Done. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 235 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
In order to be postgres compliant a COMMIT after a statement that returns an error doesn't return an error (apparently it returns an error code somewhere else in the protocol). Anyway to make this more readable I've changed all the COMMIT following an error to ROLLBACK. Comments from Reviewable |
|
Review status: 0 of 7 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 235 at r3 (raw file): Previously, vivekmenezes wrote…
Oh neat. If that's the case I think it should be changed back to COMMIT to verify that behavior otherwise we could accidentally regress and COMMIT even in the face of an error. Comments from Reviewable |
|
TFTR! Review status: 0 of 7 files reviewed at latest revision, 1 unresolved discussion. pkg/sql/logictest/testdata/logic_test/schema_change_in_txn, line 235 at r3 (raw file): Previously, mjibson (Matt Jibson) wrote…
changed back to COMMIT Comments from Reviewable |
|
bors r+ |
Merge conflict (retrying...) |
This change allows execution of all schema changes following a CREATE TABLE in a transaction. Since the CREATE TABLE is invisible during the transaction to the rest of the cluster, the schema changes can executed without changing the version of the table descriptor and without running through the schema change state machine. This change is being done to make cockroachdb more compatible with postgres. fixes cockroachdb#24626 Release note (sql change): Can follow a CREATE TABLE with schema changes like CREATE INDEX on the table in the same transaction. Release note: None
|
bors r+ |
Canceled (will resume) |
24883: dep: Bump grpc-go version r=a-robinson a=a-robinson And pull in new packages -- in particular, the encoding/proto package isn't needed for compilation but is needed at runtime. Release note: None --------------------- We should wait to merge this until they've cut the 1.12 release tag so that we aren't just at an arbitrary commit in their git history but I'm sending out the PR now so that I (or whoever would have done this) don't have to deal with debugging the missing encoding/proto package when it comes time to merge this. As tested in #17370 (comment), this gives a 5-10% boost in whole-cluster throughput and improved tail latencies when run with a highly concurrent workload. It appears to have little performance effect for lower-concurrency workloads. 25410: sql: run schema changes after CREATE TABLE in txn r=vivekmenezes a=vivekmenezes Includes a commit from #25362 and should be reviewed after that change. 25612: util: fix `retry.WithMaxAttempts` context cancelled before run. r=windchan7 a=windchan7 If context gets cancelled right after `retry.WithMaxAttempts` runs, the function passed to it will never gets run. Now `retry.WithMaxAttempts` will at least run the function once otherwise an error will be returned. Making this change because there are places such as `show_cluster_setting.go` require the passed in function to be run at least once. Otherwise there will be seg fault. Fixes: #25600. Fixes: #25603. Fixes: #25570. Fixes: #25567. Fixes: #25566. Fixes: #25511. Fixes: #25485. Release note: None 25625: storage: Adding testing knob to disable automatic lease renewals r=a-robinson a=a-robinson In order to fix the test flakes caused by automatic lease renewals Fixes #25537 Fixes #25540 Fixes #25568 Fixes #25573 Fixes #25576 Fixes #25589 Fixes #25594 Fixes #25599 Fixes #25605 Fixes #25620 Release note: None Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com> Co-authored-by: Vivek Menezes <vivek@cockroachlabs.com> Co-authored-by: Victor Chen <victor@cockroachlabs.com>
Build succeeded |
Includes a commit from #25362 and should be reviewed after that change.