github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/lock_table/acquire_idempotency (about)

     1  # -------------------------------------------------------------
     2  # In this test we acquire the same lock multiple times at different
     3  # transaction sequence numbers. The test cases correspond closely
     4  # to those in TestReplicaTxnIdempotency.
     5  # -------------------------------------------------------------
     6  
     7  new-lock-table maxlocks=10000
     8  ----
     9  
    10  # -------------------------------------------------------------
    11  # Acquire locks with sequence numbers 1, 2, and 4
    12  # -------------------------------------------------------------
    13  
    14  new-txn txn=txn1 ts=10,1 epoch=0 seq=1
    15  ----
    16  
    17  new-request r=req1 txn=txn1 ts=10,1 spans=w@a
    18  ----
    19  
    20  scan r=req1
    21  ----
    22  start-waiting: false
    23  
    24  acquire r=req1 k=a durability=u
    25  ----
    26  global: num=1
    27   lock: "a"
    28    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1]
    29  local: num=0
    30  
    31  dequeue r=req1
    32  ----
    33  global: num=1
    34   lock: "a"
    35    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1]
    36  local: num=0
    37  
    38  new-txn txn=txn1 ts=10,1 epoch=0 seq=2
    39  ----
    40  
    41  new-request r=req2 txn=txn1 ts=10,1 spans=w@a
    42  ----
    43  
    44  scan r=req2
    45  ----
    46  start-waiting: false
    47  
    48  acquire r=req2 k=a durability=u
    49  ----
    50  global: num=1
    51   lock: "a"
    52    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2]
    53  local: num=0
    54  
    55  dequeue r=req2
    56  ----
    57  global: num=1
    58   lock: "a"
    59    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2]
    60  local: num=0
    61  
    62  new-txn txn=txn1 ts=10,1 epoch=0 seq=4
    63  ----
    64  
    65  new-request r=req3 txn=txn1 ts=10,1 spans=w@a
    66  ----
    67  
    68  scan r=req3
    69  ----
    70  start-waiting: false
    71  
    72  acquire r=req3 k=a durability=u
    73  ----
    74  global: num=1
    75   lock: "a"
    76    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
    77  local: num=0
    78  
    79  dequeue r=req3
    80  ----
    81  global: num=1
    82   lock: "a"
    83    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
    84  local: num=0
    85  
    86  # -------------------------------------------------------------
    87  # Re-Acquire lock with sequence number 4
    88  # -------------------------------------------------------------
    89  
    90  new-txn txn=txn1 ts=10,1 epoch=0 seq=4
    91  ----
    92  
    93  new-request r=req3 txn=txn1 ts=10,1 spans=w@a
    94  ----
    95  
    96  scan r=req3
    97  ----
    98  start-waiting: false
    99  
   100  acquire r=req3 k=a durability=u
   101  ----
   102  global: num=1
   103   lock: "a"
   104    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
   105  local: num=0
   106  
   107  dequeue r=req3
   108  ----
   109  global: num=1
   110   lock: "a"
   111    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
   112  local: num=0
   113  
   114  # -------------------------------------------------------------
   115  # Re-Acquire lock with sequence number 2
   116  # -------------------------------------------------------------
   117  
   118  new-txn txn=txn1 ts=10,1 epoch=0 seq=2
   119  ----
   120  
   121  new-request r=req4 txn=txn1 ts=10,1 spans=w@a
   122  ----
   123  
   124  scan r=req4
   125  ----
   126  start-waiting: false
   127  
   128  acquire r=req4 k=a durability=u
   129  ----
   130  global: num=1
   131   lock: "a"
   132    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
   133  local: num=0
   134  
   135  dequeue r=req4
   136  ----
   137  global: num=1
   138   lock: "a"
   139    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 4]
   140  local: num=0
   141  
   142  # -------------------------------------------------------------
   143  # Try to acquire lock with sequence number 3. Should update the
   144  # lock's sequence history because the sequence does not already
   145  # exist in the sequence history.
   146  # -------------------------------------------------------------
   147  
   148  new-txn txn=txn1 ts=10,1 epoch=0 seq=3
   149  ----
   150  
   151  new-request r=req5 txn=txn1 ts=10,1 spans=w@a
   152  ----
   153  
   154  scan r=req5
   155  ----
   156  start-waiting: false
   157  
   158  acquire r=req5 k=a durability=u
   159  ----
   160  global: num=1
   161   lock: "a"
   162    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 3, 4]
   163  local: num=0
   164  
   165  dequeue r=req5
   166  ----
   167  global: num=1
   168   lock: "a"
   169    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 3, 4]
   170  local: num=0
   171  
   172  # -------------------------------------------------------------
   173  # Acquire lock with sequence numbers 5
   174  # -------------------------------------------------------------
   175  
   176  new-txn txn=txn1 ts=10,1 epoch=0 seq=5
   177  ----
   178  
   179  new-request r=req6 txn=txn1 ts=10,1 spans=w@a
   180  ----
   181  
   182  scan r=req6
   183  ----
   184  start-waiting: false
   185  
   186  acquire r=req6 k=a durability=u
   187  ----
   188  global: num=1
   189   lock: "a"
   190    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 3, 4, 5]
   191  local: num=0
   192  
   193  dequeue r=req6
   194  ----
   195  global: num=1
   196   lock: "a"
   197    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [1, 2, 3, 4, 5]
   198  local: num=0