github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/schema_change_retry (about) 1 # LogicTest: !3node-tenant 2 # This test reproduces https://github.com/cockroachdb/cockroach/issues/23979 3 4 # Schema changes that experienced retriable errors in RELEASE 5 # SAVEPOINT would previously deadlock. 6 7 # Prevent transaction refreshes so we encounter the necessary 8 # TransactionRetryError below. 9 10 statement ok 11 SET CLUSTER SETTING kv.transaction.max_refresh_spans_bytes = 0; 12 13 statement ok 14 BEGIN 15 16 statement ok 17 SAVEPOINT cockroach_restart 18 19 statement ok 20 CREATE TABLE t (x INT PRIMARY KEY, y INT); 21 22 # It doesn't matter that we're creating the table and index in the 23 # same transaction, but it does matter that the index creation is not 24 # the first thing in the transaction (since it would trigger a 25 # server-side retry if it were). 26 statement ok 27 CREATE INDEX y_idx ON t (y); 28 29 # Trigger a retriable error by running a scan as another user (high 30 # priority ensures that we don't block in this test). 31 user testuser 32 33 statement ok 34 BEGIN TRANSACTION PRIORITY HIGH 35 36 statement ok 37 SHOW TABLES 38 39 user root 40 41 # In the original bug, we'd deadlock inside RELEASE SAVEPOINT 42 query error TransactionRetryError 43 RELEASE SAVEPOINT cockroach_restart 44 45 # After restarting, everything's back to normal. 46 statement ok 47 SAVEPOINT cockroach_restart 48 49 statement ok 50 CREATE TABLE t (x INT PRIMARY KEY, y INT); 51 52 statement ok 53 CREATE INDEX y_idx ON t (y); 54 55 statement ok 56 RELEASE SAVEPOINT cockroach_restart 57 58 statement ok 59 COMMIT