-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: CREATE TABLE/VIEW works on non-serializable transactions, but shouldnt #17404
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Milestone
Description
Both CREATE TABLE and CREATE VIEW can modify descriptors of other tables/views than the one being created, to update either their depended-on list (for CREATE VIEW) or their index list (for CREATE TABLE with FKs).
This is done by using planner.avoidCachedDescriptor to disable use of the descriptor cache, so that the descriptor is read from KV in the same transaction. Then the descriptor is modified in-place, UpVersion is set, and written back in the same txn.
However, if the isolation level is SNAPSHOT, we run the risk of working with an outdated descriptor when committing!
It is important that DDL statements are rejected when the txn level is not at least SERIALIZABLE.
cc @cockroachdb/sql-async
Found by @andreimatei in #17310.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.