github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/lock_table/basic (about) 1 new-lock-table maxlocks=10000 2 ---- 3 4 new-txn txn=txn1 ts=10,1 epoch=0 5 ---- 6 7 # req1 will acquire locks for txn1 8 9 new-request r=req1 txn=txn1 ts=10,1 spans=r@a,b+w@c,f 10 ---- 11 12 scan r=req1 13 ---- 14 start-waiting: false 15 16 guard-state r=req1 17 ---- 18 new: state=doneWaiting 19 20 # Acquire lock on c both replicated and unreplicated. Just to trigger corner cases and since 21 # uncontended replicated locks are not tracked by lockTable. 22 acquire r=req1 k=c durability=r 23 ---- 24 global: num=0 25 local: num=0 26 27 acquire r=req1 k=c durability=u 28 ---- 29 global: num=1 30 lock: "c" 31 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 32 local: num=0 33 34 acquire r=req1 k=e durability=u 35 ---- 36 global: num=2 37 lock: "c" 38 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 39 lock: "e" 40 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 41 local: num=0 42 43 dequeue r=req1 44 ---- 45 global: num=2 46 lock: "c" 47 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 48 lock: "e" 49 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 50 local: num=0 51 52 # req2 is also for txn1 and will not wait for locks that are held by self. 53 54 new-request r=req2 txn=txn1 ts=10,2 spans=w@b,d+r@d,g 55 ---- 56 57 scan r=req2 58 ---- 59 start-waiting: false 60 61 acquire r=req2 k=b durability=u 62 ---- 63 global: num=3 64 lock: "b" 65 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,2, info: unrepl epoch: 0, seqs: [0] 66 lock: "c" 67 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 68 lock: "e" 69 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 70 local: num=0 71 72 dequeue r=req2 73 ---- 74 global: num=3 75 lock: "b" 76 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,2, info: unrepl epoch: 0, seqs: [0] 77 lock: "c" 78 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 79 lock: "e" 80 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 81 local: num=0 82 83 # txn1 holds locks on b, c, e. 84 # txn2 has a smaller timestamp than txn1. 85 new-txn txn=txn2 ts=8,12 epoch=0 86 ---- 87 88 # A read request for txn2 does not need to wait for locks held by txn1. 89 new-request r=req3 txn=txn2 ts=8,12 spans=r@a,g 90 ---- 91 92 scan r=req3 93 ---- 94 start-waiting: false 95 96 dequeue r=req3 97 ---- 98 global: num=3 99 lock: "b" 100 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,2, info: unrepl epoch: 0, seqs: [0] 101 lock: "c" 102 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 103 lock: "e" 104 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 105 local: num=0 106 107 # req4 from txn2 will conflict with locks on b, c since wants to write to [a, d). But does 108 # not conflict with lock on e since wants to read there and the read is at a lower timestamp 109 # than the lock. 110 new-request r=req4 txn=txn2 ts=8,12 spans=w@a,d+r@d,g 111 ---- 112 113 scan r=req4 114 ---- 115 start-waiting: true 116 117 guard-state r=req4 118 ---- 119 new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write 120 121 # Release lock on b since epoch of txn1 has changed. 122 update txn=txn1 ts=11,1 epoch=1 span=b 123 ---- 124 global: num=3 125 lock: "b" 126 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 127 lock: "c" 128 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 129 lock: "e" 130 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 131 local: num=0 132 133 # Still waiting, but on lock c which has a different ts in the TxnMeta. 134 135 guard-state r=req4 136 ---- 137 new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write 138 139 # Release lock on c since epoch of txn1 has changed. 140 update txn=txn1 ts=11,1 epoch=1 span=c,e 141 ---- 142 global: num=3 143 lock: "b" 144 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 145 lock: "c" 146 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 147 lock: "e" 148 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 149 local: num=0 150 151 # No longer waiting since does not conflict with lock on e. 152 153 guard-state r=req4 154 ---- 155 new: state=doneWaiting 156 157 # req4 from txn2 has a reservation on b, c with ts=8,12. And txn1 has a lock on e with ts=10,1 158 159 scan r=req4 160 ---- 161 start-waiting: false 162 163 # req4 proceeds to evaluation and discovers locks on a, f. The lock on a conflicts since req4 164 # wants to write and the lock on f conflicts because req4's read has a higher timestamp. 165 166 new-txn txn=txn3 ts=6 epoch=0 167 ---- 168 169 add-discovered r=req4 k=a txn=txn3 170 ---- 171 global: num=4 172 lock: "a" 173 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 174 queued writers: 175 active: false req: 4, txn: 00000000-0000-0000-0000-000000000002 176 lock: "b" 177 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 178 lock: "c" 179 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 180 lock: "e" 181 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 182 local: num=0 183 184 add-discovered r=req4 k=f txn=txn3 185 ---- 186 global: num=5 187 lock: "a" 188 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 189 queued writers: 190 active: false req: 4, txn: 00000000-0000-0000-0000-000000000002 191 lock: "b" 192 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 193 lock: "c" 194 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 195 lock: "e" 196 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 197 lock: "f" 198 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 199 local: num=0 200 201 # Note that guard state has not changed yet. Discovering these locks means the caller has to 202 # scan again. 203 204 should-wait r=req4 205 ---- 206 false 207 208 scan r=req4 209 ---- 210 start-waiting: true 211 212 # req4 from txn2 has a reservation on b, c with ts=8,12. And txn1 has a lock on e with ts=10,1 213 # which does not conflict. And txn3 with ts=6 has locks on a, f that do conflict. This is better 214 # viewed as: 215 # Locks: 216 # a b c d e f g 217 # holder txn3 txn1 txn3 218 # 6 10,1 6 219 # res req4 req4 220 # txn2 txn2 221 # 8,12 8,12 222 # Requests: * is active wait. 223 # req4 w* w w r r r 224 225 guard-state r=req4 226 ---- 227 new: state=waitForDistinguished txn=txn3 key="a" held=true guard-access=write 228 229 print 230 ---- 231 global: num=5 232 lock: "a" 233 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 234 queued writers: 235 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 236 distinguished req: 4 237 lock: "b" 238 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 239 lock: "c" 240 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 241 lock: "e" 242 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 243 lock: "f" 244 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 245 local: num=0 246 247 # req5 is again from transaction 1. Since it is reading from b, c, and even though txn1 248 # conflicts with the reservation holder since txn1.ts > txn2.ts, reads don't wait for 249 # reservations. 250 new-request r=req5 txn=txn1 ts=11,1 spans=r@b+r@c 251 ---- 252 253 scan r=req5 254 ---- 255 start-waiting: false 256 257 dequeue r=req5 258 ---- 259 global: num=5 260 lock: "a" 261 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 262 queued writers: 263 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 264 distinguished req: 4 265 lock: "b" 266 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 267 lock: "c" 268 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 269 lock: "e" 270 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 271 lock: "f" 272 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 273 local: num=0 274 275 # req6 from txn1 conflicts with lock at f, and reservations at b, c. 276 277 new-request r=req6 txn=txn1 ts=11,1 spans=r@f+w@b,d 278 ---- 279 280 scan r=req6 281 ---- 282 start-waiting: true 283 284 # req6 is a distinguished waiter at b. 285 # 286 # Locks: 287 # a b c d e f g 288 # holder txn3 txn1 txn3 289 # 6 10,1 6 290 # res req4 req4 291 # txn2 txn2 292 # 8,12 8,12 293 # Requests: * is active wait. 294 # req4 w* w w r r r 295 # req6 w* w r 296 # txn1 297 # 11,1 298 299 print 300 ---- 301 global: num=5 302 lock: "a" 303 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 304 queued writers: 305 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 306 distinguished req: 4 307 lock: "b" 308 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 309 queued writers: 310 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 311 distinguished req: 6 312 lock: "c" 313 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 314 lock: "e" 315 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 316 lock: "f" 317 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 318 local: num=0 319 320 guard-state r=req6 321 ---- 322 new: state=waitForDistinguished txn=txn2 key="b" held=false guard-access=write 323 324 # req7 from txn3 only wants to write to c 325 326 new-request r=req7 txn=txn3 ts=6 spans=w@c 327 ---- 328 329 scan r=req7 330 ---- 331 start-waiting: true 332 333 # Locks: 334 # a b c d e f g 335 # holder txn3 txn1 txn3 336 # 6 10,1 6 337 # res req4 req4 338 # txn2 txn2 339 # 8,12 8,12 340 # Requests: * is active wait. 341 # req4 w* w w r r r 342 # req6 w* w r 343 # txn1 344 # 11,1 345 # req7 w* 346 # txn3 347 # 6 348 349 guard-state r=req7 350 ---- 351 new: state=waitForDistinguished txn=txn2 key="c" held=false guard-access=write 352 353 print 354 ---- 355 global: num=5 356 lock: "a" 357 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 358 queued writers: 359 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 360 distinguished req: 4 361 lock: "b" 362 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 363 queued writers: 364 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 365 distinguished req: 6 366 lock: "c" 367 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 368 queued writers: 369 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 370 distinguished req: 7 371 lock: "e" 372 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 373 lock: "f" 374 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 375 local: num=0 376 377 # Release a. req4 waits at f. 378 release txn=txn3 span=a 379 ---- 380 global: num=5 381 lock: "a" 382 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 383 lock: "b" 384 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 385 queued writers: 386 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 387 distinguished req: 6 388 lock: "c" 389 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 390 queued writers: 391 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 392 distinguished req: 7 393 lock: "e" 394 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 395 lock: "f" 396 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 397 local: num=0 398 399 guard-state r=req4 400 ---- 401 new: state=waitForDistinguished txn=txn3 key="f" held=true guard-access=read 402 403 guard-state r=req6 404 ---- 405 old: state=waitForDistinguished txn=txn2 key="b" held=false guard-access=write 406 407 print 408 ---- 409 global: num=5 410 lock: "a" 411 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 412 lock: "b" 413 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 414 queued writers: 415 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 416 distinguished req: 6 417 lock: "c" 418 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 419 queued writers: 420 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 421 distinguished req: 7 422 lock: "e" 423 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 424 lock: "f" 425 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, info: repl epoch: 0, seqs: [0] 426 waiting readers: 427 req: 4, txn: 00000000-0000-0000-0000-000000000002 428 distinguished req: 4 429 local: num=0 430 431 # Release f. This will cause req4 to be done waiting. 432 433 release txn=txn3 span=f 434 ---- 435 global: num=4 436 lock: "a" 437 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 438 lock: "b" 439 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 440 queued writers: 441 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 442 distinguished req: 6 443 lock: "c" 444 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 445 queued writers: 446 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 447 distinguished req: 7 448 lock: "e" 449 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 450 local: num=0 451 452 guard-state r=req4 453 ---- 454 new: state=doneWaiting 455 456 # Locks: 457 # a b c d e f g 458 # holder txn1 459 # 10,1 460 # res req4 req4 req4 461 # txn2 txn2 txn2 462 # 8,12 8,12 8,12 463 # Requests: * is active wait. 464 # req4 w w w r r r 465 # req6 w* w r 466 # txn1 467 # 11,1 468 # req7 w* 469 # txn3 470 # 6 471 472 scan r=req4 473 ---- 474 start-waiting: false 475 476 acquire r=req4 k=b durability=r 477 ---- 478 global: num=4 479 lock: "a" 480 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 481 lock: "b" 482 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 483 queued writers: 484 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 485 distinguished req: 6 486 lock: "c" 487 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 488 queued writers: 489 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 490 distinguished req: 7 491 lock: "e" 492 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 493 local: num=0 494 495 acquire r=req4 k=c durability=r 496 ---- 497 global: num=4 498 lock: "a" 499 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 500 lock: "b" 501 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 502 queued writers: 503 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 504 distinguished req: 6 505 lock: "c" 506 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 507 queued writers: 508 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 509 distinguished req: 7 510 lock: "e" 511 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 512 local: num=0 513 514 guard-state r=req6 515 ---- 516 new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=write 517 518 guard-state r=req7 519 ---- 520 new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write 521 522 print 523 ---- 524 global: num=4 525 lock: "a" 526 res: req: 4, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 527 lock: "b" 528 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 529 queued writers: 530 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 531 distinguished req: 6 532 lock: "c" 533 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 534 queued writers: 535 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 536 distinguished req: 7 537 lock: "e" 538 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 539 local: num=0 540 541 dequeue r=req4 542 ---- 543 global: num=3 544 lock: "b" 545 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 546 queued writers: 547 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 548 distinguished req: 6 549 lock: "c" 550 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 551 queued writers: 552 active: true req: 7, txn: 00000000-0000-0000-0000-000000000003 553 distinguished req: 7 554 lock: "e" 555 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 556 local: num=0 557 558 # Locks: 559 # a b c d e f g 560 # holder txn2 txn2 txn1 561 # 8,12 8,12 10,1 562 # res 563 # Requests: * is active wait. 564 # req6 w* w r 565 # txn1 566 # 11,1 567 # req7 w* 568 # txn3 569 # 6 570 571 # Release the lock at c. The lock at e is not held by txn2 so will be ignored. 572 # req7 will get the reservation at c and will become doneWaiting. 573 release txn=txn2 span=c,f 574 ---- 575 global: num=3 576 lock: "b" 577 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 578 queued writers: 579 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 580 distinguished req: 6 581 lock: "c" 582 res: req: 7, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 583 lock: "e" 584 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 585 local: num=0 586 587 guard-state r=req7 588 ---- 589 new: state=doneWaiting 590 591 guard-state r=req6 592 ---- 593 old: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=write 594 595 print 596 ---- 597 global: num=3 598 lock: "b" 599 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0] 600 queued writers: 601 active: true req: 6, txn: 00000000-0000-0000-0000-000000000001 602 distinguished req: 6 603 lock: "c" 604 res: req: 7, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 605 lock: "e" 606 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 607 local: num=0 608 609 # Now before req7 can scan again, release the lock at b. This will cause req6 to break the 610 # reservation of req7 at c and become doneWaiting too. 611 612 release txn=txn2 span=b 613 ---- 614 global: num=3 615 lock: "b" 616 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000011,1, seq: 0 617 lock: "c" 618 res: req: 7, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 619 lock: "e" 620 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 621 local: num=0 622 623 guard-state r=req6 624 ---- 625 new: state=doneWaiting 626 627 guard-state r=req7 628 ---- 629 old: state=doneWaiting 630 631 # Both requests are doneWaiting, but req holds the reservation. The state is 632 # Locks: 633 # a b c d e f g 634 # holder txn1 635 # 10,1 636 # res req6 req6 637 # txn1 txn1 638 # 11,1 11,1 639 # Requests: * is active wait. 640 # req6 w w r 641 # txn1 642 # 11,1 643 # req7 w* 644 # txn3 645 # 6 646 647 print 648 ---- 649 global: num=3 650 lock: "b" 651 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000011,1, seq: 0 652 lock: "c" 653 res: req: 6, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000011,1, seq: 0 654 queued writers: 655 active: false req: 7, txn: 00000000-0000-0000-0000-000000000003 656 lock: "e" 657 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 658 local: num=0 659 660 scan r=req7 661 ---- 662 start-waiting: true 663 664 guard-state r=req7 665 ---- 666 new: state=waitForDistinguished txn=txn1 key="c" held=false guard-access=write 667 668 scan r=req6 669 ---- 670 start-waiting: false 671 672 # Release reservation. 673 dequeue r=req6 674 ---- 675 global: num=2 676 lock: "c" 677 res: req: 7, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 678 lock: "e" 679 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 680 local: num=0 681 682 guard-state r=req7 683 ---- 684 new: state=doneWaiting 685 686 scan r=req7 687 ---- 688 start-waiting: false 689 690 dequeue r=req7 691 ---- 692 global: num=1 693 lock: "e" 694 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 695 local: num=0 696 697 # e is still locked 698 699 new-request r=req8 txn=txn3 ts=6 spans=w@e 700 ---- 701 702 scan r=req8 703 ---- 704 start-waiting: true 705 706 guard-state r=req8 707 ---- 708 new: state=waitForDistinguished txn=txn1 key="e" held=true guard-access=write 709 710 dequeue r=req8 711 ---- 712 global: num=1 713 lock: "e" 714 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 715 local: num=0 716 717 release txn=txn1 span=c,f 718 ---- 719 global: num=0 720 local: num=0 721 722 print 723 ---- 724 global: num=0 725 local: num=0 726 727 # All requests have been retired and the lock table is empty. 728 # The following tests multiple requests from the same transaction. 729 730 new-request r=req9 txn=txn1 ts=10,1 spans=w@c 731 ---- 732 733 scan r=req9 734 ---- 735 start-waiting: false 736 737 acquire r=req9 k=c durability=u 738 ---- 739 global: num=1 740 lock: "c" 741 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 1, seqs: [0] 742 local: num=0 743 744 dequeue r=req9 745 ---- 746 global: num=1 747 lock: "c" 748 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 1, seqs: [0] 749 local: num=0 750 751 print 752 ---- 753 global: num=1 754 lock: "c" 755 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 1, seqs: [0] 756 local: num=0 757 758 new-request r=req10 txn=txn2 ts=8,12 spans=w@c 759 ---- 760 761 scan r=req10 762 ---- 763 start-waiting: true 764 765 guard-state r=req10 766 ---- 767 new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write 768 769 new-request r=req11 txn=txn3 ts=6 spans=w@c 770 ---- 771 772 scan r=req11 773 ---- 774 start-waiting: true 775 776 guard-state r=req11 777 ---- 778 new: state=waitFor txn=txn1 key="c" held=true guard-access=write 779 780 new-request r=req12 txn=txn2 ts=8,12 spans=w@c 781 ---- 782 783 scan r=req12 784 ---- 785 start-waiting: true 786 787 guard-state r=req12 788 ---- 789 new: state=waitFor txn=txn1 key="c" held=true guard-access=write 790 791 print 792 ---- 793 global: num=1 794 lock: "c" 795 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 1, seqs: [0] 796 queued writers: 797 active: true req: 10, txn: 00000000-0000-0000-0000-000000000002 798 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 799 active: true req: 12, txn: 00000000-0000-0000-0000-000000000002 800 distinguished req: 10 801 local: num=0 802 803 release txn=txn1 span=c 804 ---- 805 global: num=1 806 lock: "c" 807 res: req: 10, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 808 queued writers: 809 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 810 active: true req: 12, txn: 00000000-0000-0000-0000-000000000002 811 distinguished req: 11 812 local: num=0 813 814 guard-state r=req10 815 ---- 816 new: state=doneWaiting 817 818 guard-state r=req11 819 ---- 820 new: state=waitForDistinguished txn=txn2 key="c" held=false guard-access=write 821 822 guard-state r=req12 823 ---- 824 new: state=waitSelf 825 826 scan r=req10 827 ---- 828 start-waiting: false 829 830 print 831 ---- 832 global: num=1 833 lock: "c" 834 res: req: 10, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, seq: 0 835 queued writers: 836 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 837 active: true req: 12, txn: 00000000-0000-0000-0000-000000000002 838 distinguished req: 11 839 local: num=0 840 841 acquire r=req10 k=c durability=u 842 ---- 843 global: num=1 844 lock: "c" 845 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: unrepl epoch: 0, seqs: [0] 846 queued writers: 847 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 848 distinguished req: 11 849 local: num=0 850 851 guard-state r=req11 852 ---- 853 new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write 854 855 # Since req10 that is also txn2 has acquired the lock, req12 does not need to wait here anymore. 856 guard-state r=req12 857 ---- 858 new: state=doneWaiting 859 860 print 861 ---- 862 global: num=1 863 lock: "c" 864 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: unrepl epoch: 0, seqs: [0] 865 queued writers: 866 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 867 distinguished req: 11 868 local: num=0 869 870 dequeue r=req10 871 ---- 872 global: num=1 873 lock: "c" 874 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: unrepl epoch: 0, seqs: [0] 875 queued writers: 876 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 877 distinguished req: 11 878 local: num=0 879 880 acquire r=req12 k=c durability=r 881 ---- 882 global: num=1 883 lock: "c" 884 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0], unrepl epoch: 0, seqs: [0] 885 queued writers: 886 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 887 distinguished req: 11 888 local: num=0 889 890 dequeue r=req12 891 ---- 892 global: num=1 893 lock: "c" 894 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: repl epoch: 0, seqs: [0], unrepl epoch: 0, seqs: [0] 895 queued writers: 896 active: true req: 11, txn: 00000000-0000-0000-0000-000000000003 897 distinguished req: 11 898 local: num=0 899 900 guard-state r=req11 901 ---- 902 old: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write 903 904 release txn=txn2 span=b,d 905 ---- 906 global: num=1 907 lock: "c" 908 res: req: 11, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 909 local: num=0 910 911 guard-state r=req11 912 ---- 913 new: state=doneWaiting 914 915 print 916 ---- 917 global: num=1 918 lock: "c" 919 res: req: 11, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000006,0, seq: 0 920 local: num=0 921 922 dequeue r=req11 923 ---- 924 global: num=0 925 local: num=0 926 927 # Tests with non-transactional requests that triggered nil pointer 928 # dereference bugs. 929 930 new-request r=req13 txn=txn2 ts=8,12 spans=w@c 931 ---- 932 933 scan r=req13 934 ---- 935 start-waiting: false 936 937 acquire r=req13 k=c durability=u 938 ---- 939 global: num=1 940 lock: "c" 941 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000008,12, info: unrepl epoch: 0, seqs: [0] 942 local: num=0 943 944 new-request r=req14 txn=txn1 ts=9,0 spans=w@c 945 ---- 946 947 scan r=req14 948 ---- 949 start-waiting: true 950 951 new-request r=req15 txn=none ts=10,12 spans=r@c 952 ---- 953 954 scan r=req15 955 ---- 956 start-waiting: true 957 958 release txn=txn2 span=b,d 959 ---- 960 global: num=1 961 lock: "c" 962 res: req: 14, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, seq: 0 963 local: num=0 964 965 dequeue r=req15 966 ---- 967 global: num=1 968 lock: "c" 969 res: req: 14, txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, seq: 0 970 local: num=0 971 972 new-request r=req16 txn=none ts=10,12 spans=r@c 973 ---- 974 975 scan r=req16 976 ---- 977 start-waiting: false 978 979 dequeue r=req14 980 ---- 981 global: num=0 982 local: num=0 983 984 dequeue r=req16 985 ---- 986 global: num=0 987 local: num=0 988 989 print 990 ---- 991 global: num=0 992 local: num=0 993 994 # Test with distinguished waiter being a later request from the same 995 # transaction that eventually grabs a reservation. Triggered a bug 996 # in not replacing the distinguished waiter. 997 998 new-request r=req17 txn=txn1 ts=9,0 spans=w@c+w@d 999 ---- 1000 1001 scan r=req17 1002 ---- 1003 start-waiting: false 1004 1005 acquire r=req17 k=c durability=u 1006 ---- 1007 global: num=1 1008 lock: "c" 1009 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1010 local: num=0 1011 1012 acquire r=req17 k=d durability=u 1013 ---- 1014 global: num=2 1015 lock: "c" 1016 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1017 lock: "d" 1018 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1019 local: num=0 1020 1021 dequeue r=req17 1022 ---- 1023 global: num=2 1024 lock: "c" 1025 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1026 lock: "d" 1027 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1028 local: num=0 1029 1030 new-request r=req18 txn=txn2 ts=10,0 spans=w@c+w@d 1031 ---- 1032 1033 scan r=req18 1034 ---- 1035 start-waiting: true 1036 1037 new-request r=req19 txn=txn2 ts=10,0 spans=w@d 1038 ---- 1039 1040 scan r=req19 1041 ---- 1042 start-waiting: true 1043 1044 print 1045 ---- 1046 global: num=2 1047 lock: "c" 1048 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1049 queued writers: 1050 active: true req: 18, txn: 00000000-0000-0000-0000-000000000002 1051 distinguished req: 18 1052 lock: "d" 1053 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1054 queued writers: 1055 active: true req: 19, txn: 00000000-0000-0000-0000-000000000002 1056 distinguished req: 19 1057 local: num=0 1058 1059 release txn=txn1 span=c 1060 ---- 1061 global: num=2 1062 lock: "c" 1063 res: req: 18, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1064 lock: "d" 1065 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1066 queued writers: 1067 active: true req: 19, txn: 00000000-0000-0000-0000-000000000002 1068 distinguished req: 19 1069 local: num=0 1070 1071 guard-state r=req18 1072 ---- 1073 new: state=waitFor txn=txn1 key="d" held=true guard-access=write 1074 1075 print 1076 ---- 1077 global: num=2 1078 lock: "c" 1079 res: req: 18, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1080 lock: "d" 1081 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000009,0, info: unrepl epoch: 1, seqs: [0] 1082 queued writers: 1083 active: true req: 18, txn: 00000000-0000-0000-0000-000000000002 1084 active: true req: 19, txn: 00000000-0000-0000-0000-000000000002 1085 distinguished req: 19 1086 local: num=0 1087 1088 release txn=txn1 span=d 1089 ---- 1090 global: num=2 1091 lock: "c" 1092 res: req: 18, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1093 lock: "d" 1094 res: req: 18, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1095 queued writers: 1096 active: true req: 19, txn: 00000000-0000-0000-0000-000000000002 1097 local: num=0 1098 1099 scan r=req18 1100 ---- 1101 start-waiting: false 1102 1103 acquire r=req18 k=d durability=u 1104 ---- 1105 global: num=2 1106 lock: "c" 1107 res: req: 18, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1108 lock: "d" 1109 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1110 local: num=0 1111 1112 guard-state r=req19 1113 ---- 1114 new: state=doneWaiting 1115 1116 scan r=req19 1117 ---- 1118 start-waiting: false 1119 1120 dequeue r=req18 1121 ---- 1122 global: num=1 1123 lock: "d" 1124 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1125 local: num=0 1126 1127 dequeue r=req19 1128 ---- 1129 global: num=1 1130 lock: "d" 1131 holder: txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1132 local: num=0 1133 1134 release txn=txn2 span=d 1135 ---- 1136 global: num=0 1137 local: num=0 1138 1139 # Reservation can be broken while holding latches because a different 1140 # lock is released 1141 1142 new-request r=req20 txn=txn1 ts=10 spans=w@c 1143 ---- 1144 1145 scan r=req20 1146 ---- 1147 start-waiting: false 1148 1149 acquire r=req20 k=c durability=u 1150 ---- 1151 global: num=1 1152 lock: "c" 1153 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1154 local: num=0 1155 1156 dequeue r=req20 1157 ---- 1158 global: num=1 1159 lock: "c" 1160 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1161 local: num=0 1162 1163 new-request r=req21 txn=txn1 ts=10 spans=w@d 1164 ---- 1165 1166 scan r=req21 1167 ---- 1168 start-waiting: false 1169 1170 acquire r=req21 k=d durability=u 1171 ---- 1172 global: num=2 1173 lock: "c" 1174 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1175 lock: "d" 1176 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1177 local: num=0 1178 1179 dequeue r=req21 1180 ---- 1181 global: num=2 1182 lock: "c" 1183 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1184 lock: "d" 1185 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1186 local: num=0 1187 1188 new-request r=req22 txn=txn2 ts=10 spans=w@c+w@d 1189 ---- 1190 1191 scan r=req22 1192 ---- 1193 start-waiting: true 1194 1195 print 1196 ---- 1197 global: num=2 1198 lock: "c" 1199 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1200 queued writers: 1201 active: true req: 22, txn: 00000000-0000-0000-0000-000000000002 1202 distinguished req: 22 1203 lock: "d" 1204 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1205 local: num=0 1206 1207 new-request r=req23 txn=txn3 ts=10 spans=w@d 1208 ---- 1209 1210 scan r=req23 1211 ---- 1212 start-waiting: true 1213 1214 release txn=txn1 span=d 1215 ---- 1216 global: num=2 1217 lock: "c" 1218 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [0] 1219 queued writers: 1220 active: true req: 22, txn: 00000000-0000-0000-0000-000000000002 1221 distinguished req: 22 1222 lock: "d" 1223 res: req: 23, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 1224 local: num=0 1225 1226 guard-state r=req23 1227 ---- 1228 new: state=doneWaiting 1229 1230 scan r=req23 1231 ---- 1232 start-waiting: false 1233 1234 # holds latch on d and proceeds to evaluation, but lock on c 1235 # is released concurrently allowing req22 to break the reservation 1236 # at d. Note that reservation breaking is not constrained 1237 # by latches. 1238 1239 release txn=txn1 span=c 1240 ---- 1241 global: num=2 1242 lock: "c" 1243 res: req: 22, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1244 lock: "d" 1245 res: req: 23, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, seq: 0 1246 local: num=0 1247 1248 guard-state r=req22 1249 ---- 1250 new: state=doneWaiting 1251 1252 print 1253 ---- 1254 global: num=2 1255 lock: "c" 1256 res: req: 22, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1257 lock: "d" 1258 res: req: 22, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1259 queued writers: 1260 active: false req: 23, txn: 00000000-0000-0000-0000-000000000003 1261 local: num=0 1262 1263 acquire r=req23 k=d durability=u 1264 ---- 1265 global: num=2 1266 lock: "c" 1267 res: req: 22, txn: 00000000-0000-0000-0000-000000000002, ts: 0.000000010,0, seq: 0 1268 lock: "d" 1269 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1270 queued writers: 1271 active: false req: 22, txn: 00000000-0000-0000-0000-000000000002 1272 local: num=0 1273 1274 dequeue r=req22 1275 ---- 1276 global: num=1 1277 lock: "d" 1278 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1279 local: num=0 1280 1281 dequeue r=req23 1282 ---- 1283 global: num=1 1284 lock: "d" 1285 holder: txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [0] 1286 local: num=0 1287 1288 release txn=txn3 span=d 1289 ---- 1290 global: num=0 1291 local: num=0 1292 1293 print 1294 ---- 1295 global: num=0 1296 local: num=0