github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/lock_table/non_txn_write (about) 1 new-lock-table maxlocks=10000 2 ---- 3 4 new-txn txn=txn1 ts=10 epoch=0 5 ---- 6 7 new-txn txn=txn2 ts=10 epoch=0 8 ---- 9 10 new-txn txn=txn3 ts=10 epoch=0 11 ---- 12 13 # First locks at a, b, c are acquired by txn1 14 new-request r=req1 txn=txn1 ts=10 spans=w@a+w@b+w@c 15 ---- 16 17 scan r=req1 18 ---- 19 start-waiting: false 20 21 acquire r=req1 k=a durability=u 22 ---- 23 global: num=1 24 lock: "a" 25 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 26 local: num=0 27 28 acquire r=req1 k=b durability=u 29 ---- 30 global: num=2 31 lock: "a" 32 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 33 lock: "b" 34 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 35 local: num=0 36 37 acquire r=req1 k=c durability=u 38 ---- 39 global: num=3 40 lock: "a" 41 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 42 lock: "b" 43 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 44 lock: "c" 45 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 46 local: num=0 47 48 dequeue r=req1 49 ---- 50 global: num=3 51 lock: "a" 52 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 53 lock: "b" 54 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 55 lock: "c" 56 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 57 local: num=0 58 59 # Next, two different transactional requests wait at a and b. 60 new-request r=req2 txn=txn2 ts=10 spans=w@a 61 ---- 62 63 scan r=req2 64 ---- 65 start-waiting: true 66 67 new-request r=req3 txn=txn3 ts=10 spans=w@b 68 ---- 69 70 scan r=req3 71 ---- 72 start-waiting: true 73 74 # Next, a non-transactional request that wants to write a, b, c waits at a. 75 76 new-request r=req4 txn=none ts=10 spans=w@a+w@b+w@c 77 ---- 78 79 scan r=req4 80 ---- 81 start-waiting: true 82 83 # Next, a transactional request that arrives later than the non-transactional request waits at c 84 85 new-request r=req5 txn=txn3 ts=10 spans=w@c 86 ---- 87 88 scan r=req5 89 ---- 90 start-waiting: true 91 92 print 93 ---- 94 global: num=3 95 lock: "a" 96 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 97 queued writers: 98 active: true req: 2, txn: 00000000-0000-0000-0000-000000000002 99 active: true req: 4, txn: none 100 distinguished req: 2 101 lock: "b" 102 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 103 queued writers: 104 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 105 distinguished req: 3 106 lock: "c" 107 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 108 queued writers: 109 active: true req: 5, txn: 00000000-0000-0000-0000-000000000003 110 distinguished req: 5 111 local: num=0 112 113 # The locks at a, b, c are released. The non-transactional request waits behind 114 # the reservation holder at a. 115 116 release txn=txn1 span=a,d 117 ---- 118 global: num=3 119 lock: "a" 120 res: req: 2, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 121 queued writers: 122 active: true req: 4, txn: none 123 distinguished req: 4 124 lock: "b" 125 res: req: 3, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 126 lock: "c" 127 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 128 local: num=0 129 130 guard-state r=req2 131 ---- 132 new: state=doneWaiting 133 134 guard-state r=req3 135 ---- 136 new: state=doneWaiting 137 138 guard-state r=req4 139 ---- 140 new: state=waitForDistinguished txn=txn2 key="a" held=false guard-access=write 141 142 guard-state r=req5 143 ---- 144 new: state=doneWaiting 145 146 # Add another transactional request at a. It will wait behind the non-transactional request. 147 148 new-request r=req6 txn=txn1 ts=10 spans=w@a 149 ---- 150 151 scan r=req6 152 ---- 153 start-waiting: true 154 155 print 156 ---- 157 global: num=3 158 lock: "a" 159 res: req: 2, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 160 queued writers: 161 active: true req: 4, txn: none 162 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 163 distinguished req: 4 164 lock: "b" 165 res: req: 3, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 166 lock: "c" 167 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 168 local: num=0 169 170 # Release the reservation at a. The first waiter is non-transactional so it will not acquire the 171 # reservation. The second waiter will acquire the reservation. The non-transactional request will 172 # wait behind the reservation holder at b. 173 174 dequeue r=req2 175 ---- 176 global: num=3 177 lock: "a" 178 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 179 lock: "b" 180 res: req: 3, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 181 lock: "c" 182 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 183 local: num=0 184 185 guard-state r=req4 186 ---- 187 new: state=waitForDistinguished txn=txn3 key="b" held=false guard-access=write 188 189 guard-state r=req6 190 ---- 191 new: state=doneWaiting 192 193 print 194 ---- 195 global: num=3 196 lock: "a" 197 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 198 lock: "b" 199 res: req: 3, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 200 queued writers: 201 active: true req: 4, txn: none 202 distinguished req: 4 203 lock: "c" 204 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 205 local: num=0 206 207 # Release the reservation at b. The non-transactional waiter will be done at b, and when it gets 208 # to c it will see a reservation holder with a higher sequence num and ignore it. 209 210 dequeue r=req3 211 ---- 212 global: num=2 213 lock: "a" 214 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 215 lock: "c" 216 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 217 local: num=0 218 219 guard-state r=req4 220 ---- 221 new: state=doneWaiting 222 223 guard-state r=req5 224 ---- 225 old: state=doneWaiting 226 227 print 228 ---- 229 global: num=2 230 lock: "a" 231 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 232 lock: "c" 233 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 234 local: num=0 235 236 # Non-transactional request scans again and proceeds to evaluation and discovers a lock at c 237 238 scan r=req4 239 ---- 240 start-waiting: false 241 242 add-discovered r=req4 k=c txn=txn2 243 ---- 244 global: num=2 245 lock: "a" 246 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 247 lock: "c" 248 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: repl epoch: 0, seqs: [0] 249 queued writers: 250 active: false req: 4, txn: none 251 active: false req: 5, txn: 00000000-0000-0000-0000-000000000003 252 local: num=0 253 254 scan r=req4 255 ---- 256 start-waiting: true 257 258 scan r=req5 259 ---- 260 start-waiting: true 261 262 guard-state r=req4 263 ---- 264 new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write 265 266 guard-state r=req5 267 ---- 268 new: state=waitFor txn=txn2 key="c" held=true guard-access=write 269 270 # Release the lock. The non-transactional request does not acquire the reservation. 271 272 release txn=txn2 span=c 273 ---- 274 global: num=2 275 lock: "a" 276 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 277 lock: "c" 278 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 279 local: num=0 280 281 guard-state r=req4 282 ---- 283 new: state=doneWaiting 284 285 guard-state r=req5 286 ---- 287 new: state=doneWaiting 288 289 # Make all requests done. 290 291 dequeue r=req4 292 ---- 293 global: num=2 294 lock: "a" 295 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 296 lock: "c" 297 res: req: 5, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 298 local: num=0 299 300 dequeue r=req5 301 ---- 302 global: num=1 303 lock: "a" 304 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, seq: 0 305 local: num=0 306 307 dequeue r=req6 308 ---- 309 global: num=0 310 local: num=0