github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/txn_retry (about)

     1  # LogicTest: local
     2  
     3  # Check that we auto-retry pushed transactions which can't be refreshed - if
     4  # they're pushed while we can still auto-retry them.
     5  subtest autoretry-on-push-first-batch
     6  
     7  statement ok
     8  CREATE TABLE test_retry (
     9    k INT PRIMARY KEY
    10  )
    11  
    12  statement ok
    13  GRANT ALL ON test_retry TO testuser
    14  
    15  # Start a txn (and fix a timestamp).
    16  statement ok
    17  BEGIN
    18  
    19  # On a different connection, do a read at a higher timestamp.
    20  user testuser
    21  
    22  statement ok
    23  SELECT * FROM test.test_retry
    24  
    25  user root
    26  
    27  # Run a cluster_logical_timestamp(), so that the transaction "observes its
    28  # commit timestamp" and so can't be refreshed, and the do an insert that will
    29  # cause the txn to be pushed.
    30  statement ok
    31  SELECT cluster_logical_timestamp(); INSERT INTO test_retry VALUES (1);
    32  
    33  statement ok
    34  COMMIT