github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/concurrency_manager/deadlocks (about) 1 # ------------------------------------------------------------- 2 # Deadlock due to lock ordering. 3 # 4 # Class: lock holder aborted while pushing lock holder. 5 # 6 # Setup: txn1, txn2, txn3 acquire locks a, b, c 7 # 8 # Test: txn1, txn2, txn3 read b, c, a 9 # txn1 is aborted to break deadlock 10 # txn3 proceeds and commits 11 # txn2 proceeds and commits 12 # ------------------------------------------------------------- 13 14 subtest lock_ordering 15 16 new-txn name=txn1 ts=10,1 epoch=0 17 ---- 18 19 new-txn name=txn2 ts=10,1 epoch=0 20 ---- 21 22 new-txn name=txn3 ts=10,1 epoch=0 23 ---- 24 25 new-request name=req1w txn=txn1 ts=10,1 26 put key=a value=v 27 ---- 28 29 new-request name=req2w txn=txn2 ts=10,1 30 put key=b value=v 31 ---- 32 33 new-request name=req3w txn=txn3 ts=10,1 34 put key=c value=v 35 ---- 36 37 sequence req=req1w 38 ---- 39 [1] sequence req1w: sequencing request 40 [1] sequence req1w: acquiring latches 41 [1] sequence req1w: scanning lock table for conflicting locks 42 [1] sequence req1w: sequencing complete, returned guard 43 44 sequence req=req2w 45 ---- 46 [2] sequence req2w: sequencing request 47 [2] sequence req2w: acquiring latches 48 [2] sequence req2w: scanning lock table for conflicting locks 49 [2] sequence req2w: sequencing complete, returned guard 50 51 sequence req=req3w 52 ---- 53 [3] sequence req3w: sequencing request 54 [3] sequence req3w: acquiring latches 55 [3] sequence req3w: scanning lock table for conflicting locks 56 [3] sequence req3w: sequencing complete, returned guard 57 58 on-lock-acquired req=req1w key=a 59 ---- 60 [-] acquire lock: txn 00000001 @ a 61 62 on-lock-acquired req=req2w key=b 63 ---- 64 [-] acquire lock: txn 00000002 @ b 65 66 on-lock-acquired req=req3w key=c 67 ---- 68 [-] acquire lock: txn 00000003 @ c 69 70 finish req=req1w 71 ---- 72 [-] finish req1w: finishing request 73 74 finish req=req2w 75 ---- 76 [-] finish req2w: finishing request 77 78 finish req=req3w 79 ---- 80 [-] finish req3w: finishing request 81 82 debug-lock-table 83 ---- 84 global: num=3 85 lock: "a" 86 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 87 lock: "b" 88 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 89 lock: "c" 90 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 91 local: num=0 92 93 # -------------------------------- 94 # Setup complete, test starts here 95 # -------------------------------- 96 97 new-request name=req1r txn=txn1 ts=10,1 98 get key=b 99 ---- 100 101 new-request name=req2r txn=txn2 ts=10,1 102 get key=c 103 ---- 104 105 new-request name=req3r txn=txn3 ts=10,1 106 get key=a 107 ---- 108 109 sequence req=req1r 110 ---- 111 [4] sequence req1r: sequencing request 112 [4] sequence req1r: acquiring latches 113 [4] sequence req1r: scanning lock table for conflicting locks 114 [4] sequence req1r: waiting in lock wait-queues 115 [4] sequence req1r: pushing timestamp of txn 00000002 above 0.000000010,1 116 [4] sequence req1r: blocked on select in concurrency_test.(*cluster).PushTransaction 117 118 sequence req=req2r 119 ---- 120 [5] sequence req2r: sequencing request 121 [5] sequence req2r: acquiring latches 122 [5] sequence req2r: scanning lock table for conflicting locks 123 [5] sequence req2r: waiting in lock wait-queues 124 [5] sequence req2r: pushing timestamp of txn 00000003 above 0.000000010,1 125 [5] sequence req2r: blocked on select in concurrency_test.(*cluster).PushTransaction 126 127 sequence req=req3r 128 ---- 129 [4] sequence req1r: dependency cycle detected 00000001->00000002->00000003->00000001 130 [5] sequence req2r: dependency cycle detected 00000002->00000003->00000001->00000002 131 [6] sequence req3r: sequencing request 132 [6] sequence req3r: acquiring latches 133 [6] sequence req3r: scanning lock table for conflicting locks 134 [6] sequence req3r: waiting in lock wait-queues 135 [6] sequence req3r: pushing timestamp of txn 00000001 above 0.000000010,1 136 [6] sequence req3r: blocked on select in concurrency_test.(*cluster).PushTransaction 137 [6] sequence req3r: dependency cycle detected 00000003->00000001->00000002->00000003 138 139 debug-lock-table 140 ---- 141 global: num=3 142 lock: "a" 143 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 144 waiting readers: 145 req: 6, txn: 00000003-0000-0000-0000-000000000000 146 distinguished req: 6 147 lock: "b" 148 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 149 waiting readers: 150 req: 4, txn: 00000001-0000-0000-0000-000000000000 151 distinguished req: 4 152 lock: "c" 153 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 154 waiting readers: 155 req: 5, txn: 00000002-0000-0000-0000-000000000000 156 distinguished req: 5 157 local: num=0 158 159 # Break the deadlock by aborting txn1. 160 on-txn-updated txn=txn1 status=aborted 161 ---- 162 [-] update txn: aborting txn1 163 [4] sequence req1r: detected pusher aborted 164 [4] sequence req1r: sequencing complete, returned error: TransactionAbortedError(ABORT_REASON_PUSHER_ABORTED): <nil> 165 [6] sequence req3r: resolving intent "a" for txn 00000001 with ABORTED status 166 [6] sequence req3r: acquiring latches 167 [6] sequence req3r: scanning lock table for conflicting locks 168 [6] sequence req3r: sequencing complete, returned guard 169 170 # Txn3 can proceed and eventually commit. 171 finish req=req3r 172 ---- 173 [-] finish req3r: finishing request 174 175 on-txn-updated txn=txn3 status=committed 176 ---- 177 [-] update txn: committing txn3 178 [5] sequence req2r: resolving intent "c" for txn 00000003 with COMMITTED status 179 [5] sequence req2r: acquiring latches 180 [5] sequence req2r: scanning lock table for conflicting locks 181 [5] sequence req2r: sequencing complete, returned guard 182 183 # Txn2 can proceed and eventually commit. 184 finish req=req2r 185 ---- 186 [-] finish req2r: finishing request 187 188 on-txn-updated txn=txn2 status=committed 189 ---- 190 [-] update txn: committing txn2 191 192 reset namespace 193 ---- 194 195 subtest end 196 197 # ------------------------------------------------------------- 198 # More complex deadlock due to lock ordering where not all of 199 # the members of the deadlock are distinguished waiters. 200 # 201 # Class: lock holder aborted while pushing lock holder. 202 # 203 # Setup: txn1, txn2, txn3 acquire locks a, b, c 204 # 205 # Test: txn4 writes a 206 # txn1, txn2, txn3 write b, c, a 207 # txn1 is aborted to break deadlock 208 # txn3 proceeds and commits 209 # txn2 proceeds and commits 210 # ------------------------------------------------------------- 211 212 subtest lock_ordering_complex 213 214 new-txn name=txn1 ts=10,1 epoch=0 215 ---- 216 217 new-txn name=txn2 ts=10,1 epoch=0 218 ---- 219 220 new-txn name=txn3 ts=10,1 epoch=0 221 ---- 222 223 new-txn name=txn4 ts=10,1 epoch=0 224 ---- 225 226 new-request name=req1w txn=txn1 ts=10,1 227 put key=a value=v 228 ---- 229 230 new-request name=req2w txn=txn2 ts=10,1 231 put key=b value=v 232 ---- 233 234 new-request name=req3w txn=txn3 ts=10,1 235 put key=c value=v 236 ---- 237 238 sequence req=req1w 239 ---- 240 [1] sequence req1w: sequencing request 241 [1] sequence req1w: acquiring latches 242 [1] sequence req1w: scanning lock table for conflicting locks 243 [1] sequence req1w: sequencing complete, returned guard 244 245 sequence req=req2w 246 ---- 247 [2] sequence req2w: sequencing request 248 [2] sequence req2w: acquiring latches 249 [2] sequence req2w: scanning lock table for conflicting locks 250 [2] sequence req2w: sequencing complete, returned guard 251 252 sequence req=req3w 253 ---- 254 [3] sequence req3w: sequencing request 255 [3] sequence req3w: acquiring latches 256 [3] sequence req3w: scanning lock table for conflicting locks 257 [3] sequence req3w: sequencing complete, returned guard 258 259 on-lock-acquired req=req1w key=a 260 ---- 261 [-] acquire lock: txn 00000001 @ a 262 263 on-lock-acquired req=req2w key=b 264 ---- 265 [-] acquire lock: txn 00000002 @ b 266 267 on-lock-acquired req=req3w key=c 268 ---- 269 [-] acquire lock: txn 00000003 @ c 270 271 finish req=req1w 272 ---- 273 [-] finish req1w: finishing request 274 275 finish req=req2w 276 ---- 277 [-] finish req2w: finishing request 278 279 finish req=req3w 280 ---- 281 [-] finish req3w: finishing request 282 283 debug-lock-table 284 ---- 285 global: num=3 286 lock: "a" 287 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 288 lock: "b" 289 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 290 lock: "c" 291 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 292 local: num=0 293 294 # -------------------------------- 295 # Setup complete, test starts here 296 # -------------------------------- 297 298 new-request name=req4w txn=txn4 ts=10,1 299 put key=a value=v2 300 ---- 301 302 new-request name=req1w2 txn=txn1 ts=10,1 303 put key=b value=v2 304 ---- 305 306 new-request name=req2w2 txn=txn2 ts=10,1 307 put key=c value=v2 308 ---- 309 310 new-request name=req3w2 txn=txn3 ts=10,1 311 put key=a value=v2 312 ---- 313 314 sequence req=req4w 315 ---- 316 [4] sequence req4w: sequencing request 317 [4] sequence req4w: acquiring latches 318 [4] sequence req4w: scanning lock table for conflicting locks 319 [4] sequence req4w: waiting in lock wait-queues 320 [4] sequence req4w: pushing txn 00000001 to abort 321 [4] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 322 323 sequence req=req1w2 324 ---- 325 [5] sequence req1w2: sequencing request 326 [5] sequence req1w2: acquiring latches 327 [5] sequence req1w2: scanning lock table for conflicting locks 328 [5] sequence req1w2: waiting in lock wait-queues 329 [5] sequence req1w2: pushing txn 00000002 to abort 330 [5] sequence req1w2: blocked on select in concurrency_test.(*cluster).PushTransaction 331 332 sequence req=req2w2 333 ---- 334 [6] sequence req2w2: sequencing request 335 [6] sequence req2w2: acquiring latches 336 [6] sequence req2w2: scanning lock table for conflicting locks 337 [6] sequence req2w2: waiting in lock wait-queues 338 [6] sequence req2w2: pushing txn 00000003 to abort 339 [6] sequence req2w2: blocked on select in concurrency_test.(*cluster).PushTransaction 340 341 sequence req=req3w2 342 ---- 343 [5] sequence req1w2: dependency cycle detected 00000001->00000002->00000003->00000001 344 [6] sequence req2w2: dependency cycle detected 00000002->00000003->00000001->00000002 345 [7] sequence req3w2: sequencing request 346 [7] sequence req3w2: acquiring latches 347 [7] sequence req3w2: scanning lock table for conflicting locks 348 [7] sequence req3w2: waiting in lock wait-queues 349 [7] sequence req3w2: pushing txn 00000001 to abort 350 [7] sequence req3w2: blocked on select in concurrency_test.(*cluster).PushTransaction 351 [7] sequence req3w2: dependency cycle detected 00000003->00000001->00000002->00000003 352 353 debug-lock-table 354 ---- 355 global: num=3 356 lock: "a" 357 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 358 queued writers: 359 active: true req: 10, txn: 00000004-0000-0000-0000-000000000000 360 active: true req: 13, txn: 00000003-0000-0000-0000-000000000000 361 distinguished req: 10 362 lock: "b" 363 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 364 queued writers: 365 active: true req: 11, txn: 00000001-0000-0000-0000-000000000000 366 distinguished req: 11 367 lock: "c" 368 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 369 queued writers: 370 active: true req: 12, txn: 00000002-0000-0000-0000-000000000000 371 distinguished req: 12 372 local: num=0 373 374 # Break the deadlock by aborting txn1. 375 on-txn-updated txn=txn1 status=aborted 376 ---- 377 [-] update txn: aborting txn1 378 [4] sequence req4w: resolving intent "a" for txn 00000001 with ABORTED status 379 [4] sequence req4w: acquiring latches 380 [4] sequence req4w: scanning lock table for conflicting locks 381 [4] sequence req4w: sequencing complete, returned guard 382 [5] sequence req1w2: detected pusher aborted 383 [5] sequence req1w2: sequencing complete, returned error: TransactionAbortedError(ABORT_REASON_PUSHER_ABORTED): <nil> 384 [7] sequence req3w2: resolving intent "a" for txn 00000001 with ABORTED status 385 [7] sequence req3w2: pushing txn 00000004 to detect request deadlock 386 [7] sequence req3w2: blocked on select in concurrency_test.(*cluster).PushTransaction 387 388 # Txn4 can proceed. 389 finish req=req4w 390 ---- 391 [-] finish req4w: finishing request 392 [7] sequence req3w2: acquiring latches 393 [7] sequence req3w2: scanning lock table for conflicting locks 394 [7] sequence req3w2: sequencing complete, returned guard 395 396 # Txn3 can proceed and eventually commit. 397 finish req=req3w2 398 ---- 399 [-] finish req3w2: finishing request 400 401 on-txn-updated txn=txn3 status=committed 402 ---- 403 [-] update txn: committing txn3 404 [6] sequence req2w2: resolving intent "c" for txn 00000003 with COMMITTED status 405 [6] sequence req2w2: acquiring latches 406 [6] sequence req2w2: scanning lock table for conflicting locks 407 [6] sequence req2w2: sequencing complete, returned guard 408 409 # Txn2 can proceed and eventually commit. 410 finish req=req2w2 411 ---- 412 [-] finish req2w2: finishing request 413 414 on-txn-updated txn=txn2 status=committed 415 ---- 416 [-] update txn: committing txn2 417 418 reset namespace 419 ---- 420 421 subtest end 422 423 # ------------------------------------------------------------- 424 # Deadlock due to request ordering. 425 # 426 # Class: reservation holder aborted while pushing lock holder. 427 # 428 # Setup: txn1, txn2, txn3 acquire locks a, b, c 429 # txn4 writes to b and c 430 # txn2 commits 431 # txn4 acquires reservation for b and blocks on c 432 # 433 # Test: txn1 writes to b 434 # txn3 writes to a 435 # txn4 is aborted to break deadlock 436 # txn1 proceeds and commits 437 # txn3 proceeds and commits 438 # ------------------------------------------------------------- 439 440 subtest request_ordering_reservation_aborted_pushing_lock_holder 441 442 new-txn name=txn1 ts=10,1 epoch=0 443 ---- 444 445 new-txn name=txn2 ts=10,1 epoch=0 446 ---- 447 448 new-txn name=txn3 ts=10,1 epoch=0 449 ---- 450 451 new-txn name=txn4 ts=10,1 epoch=0 452 ---- 453 454 new-request name=req1w txn=txn1 ts=10,1 455 put key=a value=v 456 ---- 457 458 new-request name=req2w txn=txn2 ts=10,1 459 put key=b value=v 460 ---- 461 462 new-request name=req3w txn=txn3 ts=10,1 463 put key=c value=v 464 ---- 465 466 sequence req=req1w 467 ---- 468 [1] sequence req1w: sequencing request 469 [1] sequence req1w: acquiring latches 470 [1] sequence req1w: scanning lock table for conflicting locks 471 [1] sequence req1w: sequencing complete, returned guard 472 473 sequence req=req2w 474 ---- 475 [2] sequence req2w: sequencing request 476 [2] sequence req2w: acquiring latches 477 [2] sequence req2w: scanning lock table for conflicting locks 478 [2] sequence req2w: sequencing complete, returned guard 479 480 sequence req=req3w 481 ---- 482 [3] sequence req3w: sequencing request 483 [3] sequence req3w: acquiring latches 484 [3] sequence req3w: scanning lock table for conflicting locks 485 [3] sequence req3w: sequencing complete, returned guard 486 487 on-lock-acquired req=req1w key=a 488 ---- 489 [-] acquire lock: txn 00000001 @ a 490 491 on-lock-acquired req=req2w key=b 492 ---- 493 [-] acquire lock: txn 00000002 @ b 494 495 on-lock-acquired req=req3w key=c 496 ---- 497 [-] acquire lock: txn 00000003 @ c 498 499 finish req=req1w 500 ---- 501 [-] finish req1w: finishing request 502 503 finish req=req2w 504 ---- 505 [-] finish req2w: finishing request 506 507 finish req=req3w 508 ---- 509 [-] finish req3w: finishing request 510 511 debug-lock-table 512 ---- 513 global: num=3 514 lock: "a" 515 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 516 lock: "b" 517 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 518 lock: "c" 519 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 520 local: num=0 521 522 new-request name=req4w txn=txn4 ts=10,1 523 put key=b value=v2 524 put key=c value=v2 525 ---- 526 527 sequence req=req4w 528 ---- 529 [4] sequence req4w: sequencing request 530 [4] sequence req4w: acquiring latches 531 [4] sequence req4w: scanning lock table for conflicting locks 532 [4] sequence req4w: waiting in lock wait-queues 533 [4] sequence req4w: pushing txn 00000002 to abort 534 [4] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 535 536 on-txn-updated txn=txn2 status=committed 537 ---- 538 [-] update txn: committing txn2 539 [4] sequence req4w: resolving intent "b" for txn 00000002 with COMMITTED status 540 [4] sequence req4w: pushing txn 00000003 to abort 541 [4] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 542 543 debug-lock-table 544 ---- 545 global: num=3 546 lock: "a" 547 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 548 lock: "b" 549 res: req: 17, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 550 lock: "c" 551 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 552 queued writers: 553 active: true req: 17, txn: 00000004-0000-0000-0000-000000000000 554 distinguished req: 17 555 local: num=0 556 557 # -------------------------------- 558 # Setup complete, test starts here 559 # -------------------------------- 560 561 new-request name=req1w2 txn=txn1 ts=10,1 562 put key=b value=v2 563 ---- 564 565 new-request name=req3w2 txn=txn3 ts=10,1 566 put key=a value=v2 567 ---- 568 569 sequence req=req1w2 570 ---- 571 [5] sequence req1w2: sequencing request 572 [5] sequence req1w2: acquiring latches 573 [5] sequence req1w2: scanning lock table for conflicting locks 574 [5] sequence req1w2: waiting in lock wait-queues 575 [5] sequence req1w2: pushing txn 00000004 to detect request deadlock 576 [5] sequence req1w2: blocked on select in concurrency_test.(*cluster).PushTransaction 577 578 sequence req=req3w2 579 ---- 580 [4] sequence req4w: dependency cycle detected 00000004->00000003->00000001->00000004 581 [5] sequence req1w2: dependency cycle detected 00000001->00000004->00000003->00000001 582 [6] sequence req3w2: sequencing request 583 [6] sequence req3w2: acquiring latches 584 [6] sequence req3w2: scanning lock table for conflicting locks 585 [6] sequence req3w2: waiting in lock wait-queues 586 [6] sequence req3w2: pushing txn 00000001 to abort 587 [6] sequence req3w2: blocked on select in concurrency_test.(*cluster).PushTransaction 588 [6] sequence req3w2: dependency cycle detected 00000003->00000001->00000004->00000003 589 590 debug-lock-table 591 ---- 592 global: num=3 593 lock: "a" 594 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 595 queued writers: 596 active: true req: 19, txn: 00000003-0000-0000-0000-000000000000 597 distinguished req: 19 598 lock: "b" 599 res: req: 17, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 600 queued writers: 601 active: true req: 18, txn: 00000001-0000-0000-0000-000000000000 602 distinguished req: 18 603 lock: "c" 604 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 605 queued writers: 606 active: true req: 17, txn: 00000004-0000-0000-0000-000000000000 607 distinguished req: 17 608 local: num=0 609 610 # Break the deadlock by aborting txn4. 611 on-txn-updated txn=txn4 status=aborted 612 ---- 613 [-] update txn: aborting txn4 614 [4] sequence req4w: detected pusher aborted 615 [4] sequence req4w: sequencing complete, returned error: TransactionAbortedError(ABORT_REASON_PUSHER_ABORTED): <nil> 616 [5] sequence req1w2: acquiring latches 617 [5] sequence req1w2: scanning lock table for conflicting locks 618 [5] sequence req1w2: sequencing complete, returned guard 619 620 # Txn1 can proceed and eventually commit. 621 finish req=req1w2 622 ---- 623 [-] finish req1w2: finishing request 624 625 on-txn-updated txn=txn1 status=committed 626 ---- 627 [-] update txn: committing txn1 628 [6] sequence req3w2: resolving intent "a" for txn 00000001 with COMMITTED status 629 [6] sequence req3w2: acquiring latches 630 [6] sequence req3w2: scanning lock table for conflicting locks 631 [6] sequence req3w2: sequencing complete, returned guard 632 633 # Txn3 can proceed and eventually commit. 634 finish req=req3w2 635 ---- 636 [-] finish req3w2: finishing request 637 638 on-txn-updated txn=txn3 status=committed 639 ---- 640 [-] update txn: committing txn3 641 642 reset namespace 643 ---- 644 645 subtest end 646 647 # ------------------------------------------------------------- 648 # Deadlock due to request ordering. 649 # 650 # Class: lock holder aborted while pushing reservation holder. 651 # 652 # Setup: txn1, txn2, txn3 acquire locks a, b, c 653 # txn4 writes to b and c 654 # txn2 commits 655 # txn4 acquires reservation for b and blocks on c 656 # 657 # Test: txn1 writes to b 658 # txn3 writes to a 659 # txn1 is aborted to break deadlock 660 # txn3 proceeds and commits 661 # txn4 proceeds and commits 662 # ------------------------------------------------------------- 663 664 subtest request_ordering_lock_holder_aborted_pushing_reservation 665 666 new-txn name=txn1 ts=10,1 epoch=0 667 ---- 668 669 new-txn name=txn2 ts=10,1 epoch=0 670 ---- 671 672 new-txn name=txn3 ts=10,1 epoch=0 673 ---- 674 675 new-txn name=txn4 ts=10,1 epoch=0 676 ---- 677 678 new-request name=req1w txn=txn1 ts=10,1 679 put key=a value=v 680 ---- 681 682 new-request name=req2w txn=txn2 ts=10,1 683 put key=b value=v 684 ---- 685 686 new-request name=req3w txn=txn3 ts=10,1 687 put key=c value=v 688 ---- 689 690 sequence req=req1w 691 ---- 692 [1] sequence req1w: sequencing request 693 [1] sequence req1w: acquiring latches 694 [1] sequence req1w: scanning lock table for conflicting locks 695 [1] sequence req1w: sequencing complete, returned guard 696 697 sequence req=req2w 698 ---- 699 [2] sequence req2w: sequencing request 700 [2] sequence req2w: acquiring latches 701 [2] sequence req2w: scanning lock table for conflicting locks 702 [2] sequence req2w: sequencing complete, returned guard 703 704 sequence req=req3w 705 ---- 706 [3] sequence req3w: sequencing request 707 [3] sequence req3w: acquiring latches 708 [3] sequence req3w: scanning lock table for conflicting locks 709 [3] sequence req3w: sequencing complete, returned guard 710 711 on-lock-acquired req=req1w key=a 712 ---- 713 [-] acquire lock: txn 00000001 @ a 714 715 on-lock-acquired req=req2w key=b 716 ---- 717 [-] acquire lock: txn 00000002 @ b 718 719 on-lock-acquired req=req3w key=c 720 ---- 721 [-] acquire lock: txn 00000003 @ c 722 723 finish req=req1w 724 ---- 725 [-] finish req1w: finishing request 726 727 finish req=req2w 728 ---- 729 [-] finish req2w: finishing request 730 731 finish req=req3w 732 ---- 733 [-] finish req3w: finishing request 734 735 debug-lock-table 736 ---- 737 global: num=3 738 lock: "a" 739 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 740 lock: "b" 741 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 742 lock: "c" 743 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 744 local: num=0 745 746 new-request name=req4w txn=txn4 ts=10,1 747 put key=b value=v2 748 put key=c value=v2 749 ---- 750 751 sequence req=req4w 752 ---- 753 [4] sequence req4w: sequencing request 754 [4] sequence req4w: acquiring latches 755 [4] sequence req4w: scanning lock table for conflicting locks 756 [4] sequence req4w: waiting in lock wait-queues 757 [4] sequence req4w: pushing txn 00000002 to abort 758 [4] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 759 760 on-txn-updated txn=txn2 status=committed 761 ---- 762 [-] update txn: committing txn2 763 [4] sequence req4w: resolving intent "b" for txn 00000002 with COMMITTED status 764 [4] sequence req4w: pushing txn 00000003 to abort 765 [4] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 766 767 debug-lock-table 768 ---- 769 global: num=3 770 lock: "a" 771 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 772 lock: "b" 773 res: req: 23, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 774 lock: "c" 775 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 776 queued writers: 777 active: true req: 23, txn: 00000004-0000-0000-0000-000000000000 778 distinguished req: 23 779 local: num=0 780 781 # -------------------------------- 782 # Setup complete, test starts here 783 # -------------------------------- 784 785 new-request name=req1w2 txn=txn1 ts=10,1 786 put key=b value=v2 787 ---- 788 789 new-request name=req3w2 txn=txn3 ts=10,1 790 put key=a value=v2 791 ---- 792 793 sequence req=req1w2 794 ---- 795 [5] sequence req1w2: sequencing request 796 [5] sequence req1w2: acquiring latches 797 [5] sequence req1w2: scanning lock table for conflicting locks 798 [5] sequence req1w2: waiting in lock wait-queues 799 [5] sequence req1w2: pushing txn 00000004 to detect request deadlock 800 [5] sequence req1w2: blocked on select in concurrency_test.(*cluster).PushTransaction 801 802 sequence req=req3w2 803 ---- 804 [4] sequence req4w: dependency cycle detected 00000004->00000003->00000001->00000004 805 [5] sequence req1w2: dependency cycle detected 00000001->00000004->00000003->00000001 806 [6] sequence req3w2: sequencing request 807 [6] sequence req3w2: acquiring latches 808 [6] sequence req3w2: scanning lock table for conflicting locks 809 [6] sequence req3w2: waiting in lock wait-queues 810 [6] sequence req3w2: pushing txn 00000001 to abort 811 [6] sequence req3w2: blocked on select in concurrency_test.(*cluster).PushTransaction 812 [6] sequence req3w2: dependency cycle detected 00000003->00000001->00000004->00000003 813 814 debug-lock-table 815 ---- 816 global: num=3 817 lock: "a" 818 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 819 queued writers: 820 active: true req: 25, txn: 00000003-0000-0000-0000-000000000000 821 distinguished req: 25 822 lock: "b" 823 res: req: 23, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 824 queued writers: 825 active: true req: 24, txn: 00000001-0000-0000-0000-000000000000 826 distinguished req: 24 827 lock: "c" 828 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 829 queued writers: 830 active: true req: 23, txn: 00000004-0000-0000-0000-000000000000 831 distinguished req: 23 832 local: num=0 833 834 # Break the deadlock by aborting txn1. 835 on-txn-updated txn=txn1 status=aborted 836 ---- 837 [-] update txn: aborting txn1 838 [5] sequence req1w2: detected pusher aborted 839 [5] sequence req1w2: sequencing complete, returned error: TransactionAbortedError(ABORT_REASON_PUSHER_ABORTED): <nil> 840 [6] sequence req3w2: resolving intent "a" for txn 00000001 with ABORTED status 841 [6] sequence req3w2: acquiring latches 842 [6] sequence req3w2: scanning lock table for conflicting locks 843 [6] sequence req3w2: sequencing complete, returned guard 844 845 # Txn3 can proceed and eventually commit. 846 finish req=req3w2 847 ---- 848 [-] finish req3w2: finishing request 849 850 on-txn-updated txn=txn3 status=committed 851 ---- 852 [-] update txn: committing txn3 853 [4] sequence req4w: resolving intent "c" for txn 00000003 with COMMITTED status 854 [4] sequence req4w: acquiring latches 855 [4] sequence req4w: scanning lock table for conflicting locks 856 [4] sequence req4w: sequencing complete, returned guard 857 858 # Txn4 can proceed and eventually commit. 859 finish req=req4w 860 ---- 861 [-] finish req4w: finishing request 862 863 on-txn-updated txn=txn4 status=committed 864 ---- 865 [-] update txn: committing txn4 866 867 reset namespace 868 ---- 869 870 subtest end 871 872 # ------------------------------------------------------------- 873 # Deadlock due to request ordering. 874 # 875 # Class: reservation holder aborted while pushing reservation 876 # holder. 877 # 878 # Setup: txn1, txn2, txn3 acquire locks a, b, c 879 # txn4 writes to a and b 880 # txn5 writes to b and c 881 # txn1 commits 882 # txn4 acquires reservation for a and blocks on b 883 # txn2 commits 884 # txn5 acquires reservation for b and blocks on c 885 # 886 # Test: txn3 writes to a 887 # txn4 is aborted to break deadlock 888 # txn3 proceeds and commits 889 # txn5 proceeds and commits 890 # ------------------------------------------------------------- 891 892 subtest request_ordering_reservation_aborted_pushing_reservation 893 894 new-txn name=txn1 ts=10,1 epoch=0 895 ---- 896 897 new-txn name=txn2 ts=10,1 epoch=0 898 ---- 899 900 new-txn name=txn3 ts=10,1 epoch=0 901 ---- 902 903 new-txn name=txn4 ts=10,1 epoch=0 904 ---- 905 906 new-txn name=txn5 ts=10,1 epoch=0 907 ---- 908 909 new-request name=req1w txn=txn1 ts=10,1 910 put key=a value=v 911 ---- 912 913 new-request name=req2w txn=txn2 ts=10,1 914 put key=b value=v 915 ---- 916 917 new-request name=req3w txn=txn3 ts=10,1 918 put key=c value=v 919 ---- 920 921 sequence req=req1w 922 ---- 923 [1] sequence req1w: sequencing request 924 [1] sequence req1w: acquiring latches 925 [1] sequence req1w: scanning lock table for conflicting locks 926 [1] sequence req1w: sequencing complete, returned guard 927 928 sequence req=req2w 929 ---- 930 [2] sequence req2w: sequencing request 931 [2] sequence req2w: acquiring latches 932 [2] sequence req2w: scanning lock table for conflicting locks 933 [2] sequence req2w: sequencing complete, returned guard 934 935 sequence req=req3w 936 ---- 937 [3] sequence req3w: sequencing request 938 [3] sequence req3w: acquiring latches 939 [3] sequence req3w: scanning lock table for conflicting locks 940 [3] sequence req3w: sequencing complete, returned guard 941 942 on-lock-acquired req=req1w key=a 943 ---- 944 [-] acquire lock: txn 00000001 @ a 945 946 on-lock-acquired req=req2w key=b 947 ---- 948 [-] acquire lock: txn 00000002 @ b 949 950 on-lock-acquired req=req3w key=c 951 ---- 952 [-] acquire lock: txn 00000003 @ c 953 954 finish req=req1w 955 ---- 956 [-] finish req1w: finishing request 957 958 finish req=req2w 959 ---- 960 [-] finish req2w: finishing request 961 962 finish req=req3w 963 ---- 964 [-] finish req3w: finishing request 965 966 debug-lock-table 967 ---- 968 global: num=3 969 lock: "a" 970 holder: txn: 00000001-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 971 lock: "b" 972 holder: txn: 00000002-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 973 lock: "c" 974 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 975 local: num=0 976 977 new-request name=req4w txn=txn4 ts=10,1 978 put key=a value=v2 979 put key=b value=v2 980 ---- 981 982 new-request name=req5w txn=txn5 ts=10,1 983 put key=b value=v3 984 put key=c value=v3 985 ---- 986 987 sequence req=req5w 988 ---- 989 [4] sequence req5w: sequencing request 990 [4] sequence req5w: acquiring latches 991 [4] sequence req5w: scanning lock table for conflicting locks 992 [4] sequence req5w: waiting in lock wait-queues 993 [4] sequence req5w: pushing txn 00000002 to abort 994 [4] sequence req5w: blocked on select in concurrency_test.(*cluster).PushTransaction 995 996 sequence req=req4w 997 ---- 998 [5] sequence req4w: sequencing request 999 [5] sequence req4w: acquiring latches 1000 [5] sequence req4w: scanning lock table for conflicting locks 1001 [5] sequence req4w: waiting in lock wait-queues 1002 [5] sequence req4w: pushing txn 00000001 to abort 1003 [5] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 1004 1005 on-txn-updated txn=txn1 status=committed 1006 ---- 1007 [-] update txn: committing txn1 1008 [5] sequence req4w: resolving intent "a" for txn 00000001 with COMMITTED status 1009 [5] sequence req4w: pushing txn 00000002 to abort 1010 [5] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 1011 1012 on-txn-updated txn=txn2 status=committed 1013 ---- 1014 [-] update txn: committing txn2 1015 [4] sequence req5w: resolving intent "b" for txn 00000002 with COMMITTED status 1016 [4] sequence req5w: pushing txn 00000003 to abort 1017 [4] sequence req5w: blocked on select in concurrency_test.(*cluster).PushTransaction 1018 [5] sequence req4w: resolving intent "b" for txn 00000002 with COMMITTED status 1019 [5] sequence req4w: pushing txn 00000005 to detect request deadlock 1020 [5] sequence req4w: blocked on select in concurrency_test.(*cluster).PushTransaction 1021 1022 debug-lock-table 1023 ---- 1024 global: num=3 1025 lock: "a" 1026 res: req: 30, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 1027 lock: "b" 1028 res: req: 29, txn: 00000005-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 1029 queued writers: 1030 active: true req: 30, txn: 00000004-0000-0000-0000-000000000000 1031 distinguished req: 30 1032 lock: "c" 1033 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 1034 queued writers: 1035 active: true req: 29, txn: 00000005-0000-0000-0000-000000000000 1036 distinguished req: 29 1037 local: num=0 1038 1039 # -------------------------------- 1040 # Setup complete, test starts here 1041 # -------------------------------- 1042 1043 new-request name=req3w2 txn=txn3 ts=10,1 1044 put key=a value=v2 1045 ---- 1046 1047 sequence req=req3w2 1048 ---- 1049 [4] sequence req5w: dependency cycle detected 00000005->00000003->00000004->00000005 1050 [5] sequence req4w: dependency cycle detected 00000004->00000005->00000003->00000004 1051 [6] sequence req3w2: sequencing request 1052 [6] sequence req3w2: acquiring latches 1053 [6] sequence req3w2: scanning lock table for conflicting locks 1054 [6] sequence req3w2: waiting in lock wait-queues 1055 [6] sequence req3w2: pushing txn 00000004 to detect request deadlock 1056 [6] sequence req3w2: blocked on select in concurrency_test.(*cluster).PushTransaction 1057 [6] sequence req3w2: dependency cycle detected 00000003->00000004->00000005->00000003 1058 1059 debug-lock-table 1060 ---- 1061 global: num=3 1062 lock: "a" 1063 res: req: 30, txn: 00000004-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 1064 queued writers: 1065 active: true req: 31, txn: 00000003-0000-0000-0000-000000000000 1066 distinguished req: 31 1067 lock: "b" 1068 res: req: 29, txn: 00000005-0000-0000-0000-000000000000, ts: 0.000000010,1, seq: 0 1069 queued writers: 1070 active: true req: 30, txn: 00000004-0000-0000-0000-000000000000 1071 distinguished req: 30 1072 lock: "c" 1073 holder: txn: 00000003-0000-0000-0000-000000000000, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 1074 queued writers: 1075 active: true req: 29, txn: 00000005-0000-0000-0000-000000000000 1076 distinguished req: 29 1077 local: num=0 1078 1079 # Break the deadlock by aborting txn4. 1080 on-txn-updated txn=txn4 status=aborted 1081 ---- 1082 [-] update txn: aborting txn4 1083 [5] sequence req4w: detected pusher aborted 1084 [5] sequence req4w: sequencing complete, returned error: TransactionAbortedError(ABORT_REASON_PUSHER_ABORTED): <nil> 1085 [6] sequence req3w2: acquiring latches 1086 [6] sequence req3w2: scanning lock table for conflicting locks 1087 [6] sequence req3w2: sequencing complete, returned guard 1088 1089 # Txn3 can proceed and eventually commit. 1090 finish req=req3w2 1091 ---- 1092 [-] finish req3w2: finishing request 1093 1094 on-txn-updated txn=txn3 status=committed 1095 ---- 1096 [-] update txn: committing txn3 1097 [4] sequence req5w: resolving intent "c" for txn 00000003 with COMMITTED status 1098 [4] sequence req5w: acquiring latches 1099 [4] sequence req5w: scanning lock table for conflicting locks 1100 [4] sequence req5w: sequencing complete, returned guard 1101 1102 # Txn5 can proceed and eventually commit. 1103 finish req=req5w 1104 ---- 1105 [-] finish req5w: finishing request 1106 1107 on-txn-updated txn=txn5 status=committed 1108 ---- 1109 [-] update txn: committing txn5 1110 1111 reset namespace 1112 ---- 1113 1114 subtest end