forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1f9534b
committed
Fix torn-page, unlogged xid and further risks from heap_update().
When heap_update needs to look for a page for the new tuple version,because the current one doesn't have sufficient free space, or whencolumns have to be processed by the tuple toaster, it has to release thelock on the old page during that. Otherwise there'd be lock ordering andlock nesting issues.To avoid concurrent sessions from trying to update / delete / lock thetuple while the page's content lock is released, the tuple's xmax is setto the current session's xid.That unfortunately was done without any WAL logging, thereby violatingthe rule that no XIDs may appear on disk, without an according WALrecord. If the database were to crash / fail over when the page levellock is released, and some activity lead to the page being written outto disk, the xid could end up being reused; potentially leading to therow becoming invisible.There might be additional risks by not having t_ctid point at the tupleitself, without having set the appropriate lock infomask fields.To fix, compute the appropriate xmax/infomask combination for lockingthe tuple, and perform WAL logging using the existing XLOG_HEAP_LOCKrecord. That allows the fix to be backpatched.This issue has existed for a long time. There appears to have beenpartial attempts at preventing dangers, but these never have fully beenimplemented, and were removed a long time ago, in1191916 (cf. HEAP_XMAX_UNLOGGED).In master / 9.6, there's an additional issue, namely that thevisibilitymap's freeze bit isn't reset at that point yet. Since that's anew issue, introduced only ina892234, that'll be fixed in aseparate commit.Author: Masahiko Sawada and Andres FreundReported-By: Different aspects by Thomas Munro, Noah Misch, and othersDiscussion: CAEepm=3fWAbWryVW9swHyLTY4sXVf0xbLvXqOwUoDiNCx9mBjQ@mail.gmail.comBackpatch: 9.1/all supported versions1 parentb33e81c commit1f9534b
1 file changed
+73
-23
lines changedLines changed: 73 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3232 | 3232 |
| |
3233 | 3233 |
| |
3234 | 3234 |
| |
3235 |
| - | |
3236 |
| - | |
| 3235 | + | |
3237 | 3236 |
| |
3238 | 3237 |
| |
3239 | 3238 |
| |
| |||
3675 | 3674 |
| |
3676 | 3675 |
| |
3677 | 3676 |
| |
3678 |
| - | |
3679 |
| - | |
| 3677 | + | |
| 3678 | + | |
3680 | 3679 |
| |
3681 | 3680 |
| |
3682 | 3681 |
| |
| |||
3700 | 3699 |
| |
3701 | 3700 |
| |
3702 | 3701 |
| |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
3703 | 3734 |
| |
3704 | 3735 |
| |
3705 | 3736 |
| |
3706 | 3737 |
| |
3707 | 3738 |
| |
3708 |
| - | |
3709 |
| - | |
3710 |
| - | |
3711 |
| - | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
3712 | 3743 |
| |
3713 |
| - | |
| 3744 | + | |
| 3745 | + | |
3714 | 3746 |
| |
3715 |
| - | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
3716 | 3769 |
| |
3717 | 3770 |
| |
3718 | 3771 |
| |
| |||
3783 | 3836 |
| |
3784 | 3837 |
| |
3785 | 3838 |
| |
3786 |
| - | |
3787 | 3839 |
| |
3788 | 3840 |
| |
3789 | 3841 |
| |
| |||
3870 | 3922 |
| |
3871 | 3923 |
| |
3872 | 3924 |
| |
3873 |
| - | |
3874 |
| - | |
3875 |
| - | |
3876 |
| - | |
3877 |
| - | |
3878 |
| - | |
3879 |
| - | |
3880 |
| - | |
3881 |
| - | |
3882 |
| - | |
3883 |
| - | |
3884 |
| - | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
3885 | 3935 |
| |
3886 | 3936 |
| |
3887 | 3937 |
| |
|
0 commit comments
Comments
(0)