forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: new session variable
strict_ddl_atomicity
Previously, CockroachDB always accepted DDL inside explicit txns (BEGIN...COMMIT) and would issue some of these DDL statements as asynchronous jobs after the rest of the txn was committed successfully. If that DDL subsequently failed, a client would also get error XXA00 to signal this error. However at that point the txn also would be both partially committed and partially rolled back. This is in effect an atomicity violation. It was considered to be acceptable because in practice most clients using DDL inside BEGIN...COMMIT do not, in fact, expect ACID semantics in those cases. So it was considered OK to not deliver ACID semantics in certain cases. Except that we now have clients that do want us to "do the right thing" and never allow a situation that _could_ yield atomicity violations. This patch makes a step in this direction by introducing a new session variable `strict_ddl_atomicity`, which defaults to `false` for compatibility with existing CockroachDB 19.2 clients and that of previous CockroachDB versions. When this setting is enabled / set to `true`, any DDL that would be otherwise be processed asynchronously and risk triggering error XXA00 is now fully disallowed, with the following error: ``` pq: unimplemented: cannot run this DDL statement inside BEGIN..COMMIT as its atomicity cannot be guaranteed HINT: You have attempted to use a feature that is not yet implemented. See: cockroachdb#42061 -- You can set the session variable 'strict_ddl_atomicity' to false if you are willing to accept atomicity violations. ``` Other DDL statements without async processing are still allowed without triggering that error. Examples of rejected DDL include but are not limited to: CREATE INDEX, ALTER ADD CONSTRAINT, ADD COLUMN with DEFAULT, DROP INDEX. Examples of DDL that's still processed: RENAME COLUMN, RENAME TABLE, ALTER INDEX CONFIGURE ZONE. Release note (sql change): a SQL client can now request strict atomicity for mixed DDL/DML transactions with the new session variable `strict_ddl_atomicity`, which defaults to `false`. When this variable is set to `true`, CockroachDB will refuse to accept processing those specific DDL statements inside BEGIN...COMMIT for which it cannot guarantee atomic processing (other DDL statements are still allowed).
- Loading branch information
Showing
7 changed files
with
57 additions
and
0 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
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