forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3c27944
committed
Make XactLockTableWait work for transactions that are not yet self-locked
XactLockTableWait assumed that its xid argument has already added itselfto the lock table. That assumption led to another assumption that iflocking the xid has succeeded but the xid is reported as still inprogress, then the input xid must have been a subtransaction.These assumptions hold true for the original uses of this code inlocking related to on-disk tuples, but they break down in logicalreplication slot snapshot building -- in particular, when a standbysnapshot logged contains an xid that's already in ProcArray but not yetin the lock table. This leads to assertion failures that can bereproduced all the way back to 9.4, when logical decoding wasintroduced.To fix, change SubTransGetParent to SubTransGetTopmostTransaction whichhas a slightly different API: it returns the argument Xid if there is noparent, and it goes all the way to the top instead of moving up thelevels one by one. Also, to avoid busy-waiting, add a 1ms sleep to givethe other process time to register itself in the lock table.For consistency, change ConditionalXactLockTableWait the same way.Author: Petr JelínekDiscussion:https://postgr.es/m/1B3E32D8-FCF4-40B4-AEF9-5C0E3AC57969@postgrespro.ruReported-by: Konstantin KnizhnikDiagnosed-by: Stas Kelvich, Petr JelínekReviewed-by: Andres Freund, Robert Haas1 parent6fcde24 commit3c27944
1 file changed
+28
-2
lines changedLines changed: 28 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
557 | 557 |
| |
558 | 558 |
| |
559 | 559 |
| |
| 560 | + | |
560 | 561 |
| |
561 | 562 |
| |
562 | 563 |
| |
| |||
590 | 591 |
| |
591 | 592 |
| |
592 | 593 |
| |
593 |
| - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
594 | 614 |
| |
595 | 615 |
| |
596 | 616 |
| |
| |||
607 | 627 |
| |
608 | 628 |
| |
609 | 629 |
| |
| 630 | + | |
610 | 631 |
| |
611 | 632 |
| |
612 | 633 |
| |
| |||
622 | 643 |
| |
623 | 644 |
| |
624 | 645 |
| |
625 |
| - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
626 | 652 |
| |
627 | 653 |
| |
628 | 654 |
| |
|
0 commit comments
Comments
(0)