forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commiteffe7d9
committed
Make release of 2PC identifier and locks consistent in COMMIT PREPARED
When preparing a transaction in two-phase commit, a dummy PGPROC entryholding the GID used for the transaction is registered, which getsreleased once COMMIT PREPARED is run. Prior releasing its shared memorystate, all the locks taken in the prepared transaction are releasedusing a dedicated set of callbacks (pgstat and multixact having similarcallbacks), which may cause the locks to be released before the GID isset free.Hence, there is a small window where lock conflicts could happen, forexample:- Transaction A releases its locks, still holding its GID in sharedmemory.- Transaction B held a lock which conflicted with locks of transactionA.- Transaction B continues its processing, reusing the same GID astransaction A.- Transaction B fails because of a conflicting GID, already in use bytransaction A.This commit changes the shared memory state release so as post-commitcallbacks and predicate lock cleanup happen consistently with the sharedmemory state cleanup for the dummy PGPROC entry. The race window issmall and 2PC had this issue from the start, so no backpatch is done.On top if that fixes discussed involved ABI breakages, which are notwelcome in stable branches.Reported-by: Oleksii Kliukin, Ildar MusinDiagnosed-by: Oleksii Kliukin, Ildar MusinAuthor: Michael PaquierReviewed-by: Masahiko Sawada, Oleksii KliukinDiscussion:https://postgr.es/m/BF9B38A4-2BFF-46E8-BA87-A2D00A8047A6@hintbits.com1 parent29ddb54 commiteffe7d9
File tree
4 files changed
+44
-19
lines changed- src
- backend
- access/transam
- storage/lmgr
- include/access
4 files changed
+44
-19
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1713 | 1713 |
| |
1714 | 1714 |
| |
1715 | 1715 |
| |
1716 |
| - | |
| 1716 | + | |
1717 | 1717 |
| |
1718 | 1718 |
| |
1719 | 1719 |
| |
| |||
1755 | 1755 |
| |
1756 | 1756 |
| |
1757 | 1757 |
| |
1758 |
| - | |
| 1758 | + | |
1759 | 1759 |
| |
1760 | 1760 |
| |
1761 | 1761 |
| |
| |||
1776 | 1776 |
| |
1777 | 1777 |
| |
1778 | 1778 |
| |
1779 |
| - | |
| 1779 | + | |
1780 | 1780 |
| |
1781 | 1781 |
| |
1782 | 1782 |
| |
|
Lines changed: 36 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
801 | 801 |
| |
802 | 802 |
| |
803 | 803 |
| |
| 804 | + | |
| 805 | + | |
| 806 | + | |
804 | 807 |
| |
805 | 808 |
| |
806 |
| - | |
| 809 | + | |
807 | 810 |
| |
808 | 811 |
| |
809 | 812 |
| |
810 | 813 |
| |
811 | 814 |
| |
812 | 815 |
| |
813 | 816 |
| |
| 817 | + | |
| 818 | + | |
814 | 819 |
| |
815 | 820 |
| |
816 | 821 |
| |
817 | 822 |
| |
818 | 823 |
| |
819 | 824 |
| |
820 | 825 |
| |
821 |
| - | |
| 826 | + | |
| 827 | + | |
822 | 828 |
| |
823 | 829 |
| |
824 | 830 |
| |
| |||
832 | 838 |
| |
833 | 839 |
| |
834 | 840 |
| |
835 |
| - | |
| 841 | + | |
| 842 | + | |
836 | 843 |
| |
837 | 844 |
| |
838 | 845 |
| |
| |||
849 | 856 |
| |
850 | 857 |
| |
851 | 858 |
| |
852 |
| - | |
| 859 | + | |
| 860 | + | |
853 | 861 |
| |
854 | 862 |
| |
855 |
| - | |
| 863 | + | |
856 | 864 |
| |
857 |
| - | |
| 865 | + | |
858 | 866 |
| |
859 | 867 |
| |
860 | 868 |
| |
861 | 869 |
| |
862 | 870 |
| |
863 | 871 |
| |
864 | 872 |
| |
| 873 | + | |
| 874 | + | |
| 875 | + | |
865 | 876 |
| |
866 | 877 |
| |
867 |
| - | |
| 878 | + | |
868 | 879 |
| |
869 |
| - | |
| 880 | + | |
870 | 881 |
| |
871 | 882 |
| |
872 | 883 |
| |
| |||
1560 | 1571 |
| |
1561 | 1572 |
| |
1562 | 1573 |
| |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
1563 | 1582 |
| |
1564 | 1583 |
| |
1565 | 1584 |
| |
| |||
1568 | 1587 |
| |
1569 | 1588 |
| |
1570 | 1589 |
| |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1571 | 1599 |
| |
1572 | 1600 |
| |
1573 | 1601 |
| |
| |||
1577 | 1605 |
| |
1578 | 1606 |
| |
1579 | 1607 |
| |
1580 |
| - | |
1581 |
| - | |
1582 |
| - | |
1583 | 1608 |
| |
1584 | 1609 |
| |
1585 | 1610 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3243 | 3243 |
| |
3244 | 3244 |
| |
3245 | 3245 |
| |
3246 |
| - | |
| 3246 | + | |
3247 | 3247 |
| |
3248 | 3248 |
| |
3249 | 3249 |
| |
| |||
4034 | 4034 |
| |
4035 | 4035 |
| |
4036 | 4036 |
| |
4037 |
| - | |
| 4037 | + | |
4038 | 4038 |
| |
4039 | 4039 |
| |
4040 | 4040 |
| |
| |||
4247 | 4247 |
| |
4248 | 4248 |
| |
4249 | 4249 |
| |
4250 |
| - | |
| 4250 | + | |
4251 | 4251 |
| |
4252 | 4252 |
| |
4253 | 4253 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
37 |
| - | |
38 |
| - | |
| 37 | + | |
| 38 | + | |
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
|
0 commit comments
Comments
(0)