Commit 8eace46
committed
Fix race condition in reading commit timestamps
If a user requests the commit timestamp for a transaction old enough
that its data is concurrently being truncated away by vacuum at just the
right time, they would receive an ugly internal file-not-found error
message from slru.c rather than the expected NULL return value.
In a primary server, the window for the race is very small: the lookup
has to occur exactly between the two calls by vacuum, and there's not a
lot that happens between them (mostly just a multixact truncate). In a
standby server, however, the window is larger because the truncation is
executed as soon as the WAL record for it is replayed, but the advance
of the oldest-Xid is not executed until the next checkpoint record.
To fix in the primary, simply reverse the order of operations in
vac_truncate_clog. To fix in the standby, augment the WAL truncation
record so that the standby is aware of the new oldest-XID value and can
apply the update immediately. WAL version bumped because of this.
No backpatch, because of the low importance of the bug and its rarity.
Author: Craig Ringer
Reviewed-By: Petr Jelínek, Peter Eisentraut
Discussion: https://postgr.es/m/CAMsr+YFhVtRQT1VAwC+WGbbxZZRzNou=N9Ed-FrCqkwQ8H8oJQ@mail.gmail.com1 parent 8b0fec9 commit 8eace46
File tree
5 files changed
+34
-13
lines changed- src
- backend
- access
- rmgrdesc
- transam
- commands
- include/access
5 files changed
+34
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
827 | | - | |
| 827 | + | |
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| |||
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
| 913 | + | |
914 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
915 | 920 | | |
916 | | - | |
| 921 | + | |
917 | 922 | | |
918 | 923 | | |
919 | 924 | | |
| |||
967 | 972 | | |
968 | 973 | | |
969 | 974 | | |
970 | | - | |
| 975 | + | |
971 | 976 | | |
972 | | - | |
| 977 | + | |
973 | 978 | | |
974 | 979 | | |
975 | 980 | | |
976 | 981 | | |
977 | 982 | | |
978 | | - | |
| 983 | + | |
979 | 984 | | |
980 | | - | |
| 985 | + | |
981 | 986 | | |
982 | 987 | | |
983 | 988 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1152 | 1152 | | |
1153 | 1153 | | |
1154 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1155 | 1164 | | |
1156 | 1165 | | |
1157 | 1166 | | |
| |||
1167 | 1176 | | |
1168 | 1177 | | |
1169 | 1178 | | |
1170 | | - | |
1171 | 1179 | | |
1172 | 1180 | | |
1173 | 1181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments