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

     1  # Tests where a request is a non-active waiter.
     2  
     3  new-lock-table maxlocks=10000
     4  ----
     5  
     6  new-txn txn=txn1 ts=10 epoch=0
     7  ----
     8  
     9  new-txn txn=txn2 ts=10 epoch=0
    10  ----
    11  
    12  new-request r=req1 txn=txn1 ts=10 spans=w@a+r@b+w@c
    13  ----
    14  
    15  scan r=req1
    16  ----
    17  start-waiting: false
    18  
    19  add-discovered r=req1 k=a txn=txn2
    20  ----
    21  global: num=1
    22   lock: "a"
    23    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    24     queued writers:
    25      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    26  local: num=0
    27  
    28  add-discovered r=req1 k=b txn=txn2
    29  ----
    30  global: num=2
    31   lock: "a"
    32    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    33     queued writers:
    34      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    35   lock: "b"
    36    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    37  local: num=0
    38  
    39  add-discovered r=req1 k=c txn=txn2
    40  ----
    41  global: num=3
    42   lock: "a"
    43    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    44     queued writers:
    45      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    46   lock: "b"
    47    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    48   lock: "c"
    49    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    50     queued writers:
    51      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    52  local: num=0
    53  
    54  # req1 is not in the queue for "b" as readers are never inactive waiters.
    55  
    56  print
    57  ----
    58  global: num=3
    59   lock: "a"
    60    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    61     queued writers:
    62      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    63   lock: "b"
    64    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    65   lock: "c"
    66    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    67     queued writers:
    68      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    69  local: num=0
    70  
    71  new-request r=req2 txn=txn1 ts=10 spans=w@c
    72  ----
    73  
    74  scan r=req2
    75  ----
    76  start-waiting: true
    77  
    78  # req2 is the distinguished waiter at "c".
    79  
    80  print
    81  ----
    82  global: num=3
    83   lock: "a"
    84    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    85     queued writers:
    86      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    87   lock: "b"
    88    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    89   lock: "c"
    90    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
    91     queued writers:
    92      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
    93      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
    94     distinguished req: 2
    95  local: num=0
    96  
    97  scan r=req1
    98  ----
    99  start-waiting: true
   100  
   101  guard-state r=req1
   102  ----
   103  new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write
   104  
   105  print
   106  ----
   107  global: num=3
   108   lock: "a"
   109    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   110     queued writers:
   111      active: true req: 1, txn: 00000000-0000-0000-0000-000000000001
   112     distinguished req: 1
   113   lock: "b"
   114    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   115   lock: "c"
   116    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   117     queued writers:
   118      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
   119      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   120     distinguished req: 2
   121  local: num=0
   122  
   123  # req1 waits at "c" but not as distinguished waiter.
   124  release txn=txn2 span=a
   125  ----
   126  global: num=3
   127   lock: "a"
   128    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   129   lock: "b"
   130    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   131   lock: "c"
   132    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   133     queued writers:
   134      active: false req: 1, txn: 00000000-0000-0000-0000-000000000001
   135      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   136     distinguished req: 2
   137  local: num=0
   138  
   139  guard-state r=req1
   140  ----
   141  new: state=waitFor txn=txn2 key="c" held=true guard-access=write
   142  
   143  print
   144  ----
   145  global: num=3
   146   lock: "a"
   147    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   148   lock: "b"
   149    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   150   lock: "c"
   151    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   152     queued writers:
   153      active: true req: 1, txn: 00000000-0000-0000-0000-000000000001
   154      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   155     distinguished req: 2
   156  local: num=0
   157  
   158  # req1 waits at "b" as reader.
   159  
   160  release txn=txn2 span=c
   161  ----
   162  global: num=3
   163   lock: "a"
   164    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   165   lock: "b"
   166    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   167   lock: "c"
   168    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   169     queued writers:
   170      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   171  local: num=0
   172  
   173  guard-state r=req1
   174  ----
   175  new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=read
   176  
   177  guard-state r=req2
   178  ----
   179  new: state=waitSelf
   180  
   181  print
   182  ----
   183  global: num=3
   184   lock: "a"
   185    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   186   lock: "b"
   187    holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0]
   188     waiting readers:
   189      req: 1, txn: 00000000-0000-0000-0000-000000000001
   190     distinguished req: 1
   191   lock: "c"
   192    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   193     queued writers:
   194      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   195  local: num=0
   196  
   197  # req1 is done waiting.
   198  
   199  release txn=txn2 span=b
   200  ----
   201  global: num=2
   202   lock: "a"
   203    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   204   lock: "c"
   205    res: req: 1, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   206     queued writers:
   207      active: true req: 2, txn: 00000000-0000-0000-0000-000000000001
   208  local: num=0
   209  
   210  guard-state r=req1
   211  ----
   212  new: state=doneWaiting
   213  
   214  dequeue r=req1
   215  ----
   216  global: num=1
   217   lock: "c"
   218    res: req: 2, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0
   219  local: num=0
   220  
   221  guard-state r=req2
   222  ----
   223  new: state=doneWaiting
   224  
   225  dequeue r=req2
   226  ----
   227  global: num=0
   228  local: num=0