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

     1  # Waiting states when waiting for reservation or lock holder from same txn.
     2  
     3  new-lock-table maxlocks=10000
     4  ----
     5  
     6  # ---------------------------------------------------------------------------------
     7  # req4 is waiting on locked "a", and req2 from the same txn acquires the
     8  # reservation. req4 transitions to waitForSelf state
     9  # ---------------------------------------------------------------------------------
    10  
    11  new-txn txn=txn1 ts=10 epoch=0
    12  ----
    13  
    14  new-txn txn=txn2 ts=10 epoch=0
    15  ----
    16  
    17  new-txn txn=txn3 ts=10 epoch=0
    18  ----
    19  
    20  new-request r=req1 txn=txn1 ts=10 spans=w@a
    21  ----
    22  
    23  new-request r=req2 txn=txn2 ts=10 spans=w@a
    24  ----
    25  
    26  new-request r=req3 txn=txn3 ts=10 spans=w@a
    27  ----
    28  
    29  new-request r=req4 txn=txn2 ts=10 spans=w@a
    30  ----
    31  
    32  scan r=req1
    33  ----
    34  start-waiting: false
    35  
    36  acquire r=req1 k=a durability=u
    37  ----
    38  global: num=1
    39   lock: "a"
    40    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0]
    41  local: num=0
    42  
    43  dequeue r=req1
    44  ----
    45  global: num=1
    46   lock: "a"
    47    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0]
    48  local: num=0
    49  
    50  scan r=req2
    51  ----
    52  start-waiting: true
    53  
    54  scan r=req3
    55  ----
    56  start-waiting: true
    57  
    58  scan r=req4
    59  ----
    60  start-waiting: true
    61  
    62  guard-state r=req2
    63  ----
    64  new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=write
    65  
    66  guard-state r=req3
    67  ----
    68  new: state=waitFor txn=txn1 key="a" held=true guard-access=write
    69  
    70  guard-state r=req4
    71  ----
    72  new: state=waitFor txn=txn1 key="a" held=true guard-access=write
    73  
    74  print
    75  ----
    76  global: num=1
    77   lock: "a"
    78    holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0]
    79     queued writers:
    80      active: true req: 2, txn: 00000000-0000-0000-0000-000000000002
    81      active: true req: 3, txn: 00000000-0000-0000-0000-000000000003
    82      active: true req: 4, txn: 00000000-0000-0000-0000-000000000002
    83     distinguished req: 2
    84  local: num=0
    85  
    86  release txn=txn1 span=a
    87  ----
    88  global: num=1
    89   lock: "a"
    90    res: req: 2, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0
    91     queued writers:
    92      active: true req: 3, txn: 00000000-0000-0000-0000-000000000003
    93      active: true req: 4, txn: 00000000-0000-0000-0000-000000000002
    94     distinguished req: 3
    95  local: num=0
    96  
    97  guard-state r=req2
    98  ----
    99  new: state=doneWaiting
   100  
   101  guard-state r=req3
   102  ----
   103  new: state=waitForDistinguished txn=txn2 key="a" held=false guard-access=write
   104  
   105  guard-state r=req4
   106  ----
   107  new: state=waitSelf
   108  
   109  print
   110  ----
   111  global: num=1
   112   lock: "a"
   113    res: req: 2, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0
   114     queued writers:
   115      active: true req: 3, txn: 00000000-0000-0000-0000-000000000003
   116      active: true req: 4, txn: 00000000-0000-0000-0000-000000000002
   117     distinguished req: 3
   118  local: num=0
   119  
   120  # Stays in waitSelf state if scans again.
   121  scan r=req4
   122  ----
   123  start-waiting: true
   124  
   125  guard-state r=req4
   126  ----
   127  new: state=waitSelf
   128  
   129  # ---------------------------------------------------------------------------------
   130  # req4 is waiting on reserved "a", and req2 from the same txn acquires the
   131  # lock. req4 stops waiting
   132  # ---------------------------------------------------------------------------------
   133  
   134  acquire r=req2 k=a durability=u
   135  ----
   136  global: num=1
   137   lock: "a"
   138    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0]
   139     queued writers:
   140      active: true req: 3, txn: 00000000-0000-0000-0000-000000000003
   141     distinguished req: 3
   142  local: num=0
   143  
   144  guard-state r=req3
   145  ----
   146  new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write
   147  
   148  guard-state r=req4
   149  ----
   150  new: state=doneWaiting
   151  
   152  scan r=req4
   153  ----
   154  start-waiting: false