- Notifications
You must be signed in to change notification settings - Fork5
Commitd372cb1
committed
Fix handling of multixacts predating pg_upgrade
After pg_upgrade, it is possible that some tuples' Xmax have multixactscorresponding to the old installation; such multixacts cannot haverunning members anymore. In many code sites we already know not to readthem and clobber them silently, but at least when VACUUM tries to freezea multixact or determine whether one needs freezing, there's an attemptto resolve it to its member transactions by calling GetMultiXactIdMembers,and if the multixact value is "in the future" with regards to thecurrent valid multixact range, an error like this is raised: ERROR: MultiXactId 123 has not been created yet -- apparent wraparoundand vacuuming fails. Per discussion with Andrew Gierth, it is completelybogus to try to resolve multixacts coming from before a pg_upgrade,regardless of where they stand with regards to the current validmultixact range.It's possible to get from under this problem by doing SELECT FOR UPDATEof the problem tuples, but if tables are large, this is slow andtedious, so a more thorough solution is desirable.To fix, we realize that multixacts in xmax created in 9.2 and previoushave a specific bit pattern that is never used in 9.3 and later (wealready knew this, per comments and infomask tests sprinkled in variousplaces, but we weren't leveraging this knowledge appropriately).Whenever the infomask of the tuple matches that bit pattern, we justignore the multixact completely as if Xmax wasn't set; or, in the caseof tuple freezing, we act as if an unwanted value is set and clobber itwithout decoding. This guarantees that no errors will be raised, andthat the values will be progressively removed until all tables areclean. Most callers of GetMultiXactIdMembers are patched to recognizedirectly that the value is a removable "empty" multixact and avoidcalling GetMultiXactIdMembers altogether.To avoid changing the signature of GetMultiXactIdMembers() in backbranches, we keep the "allow_old" boolean flag but rename it to"from_pgupgrade"; if the flag is true, we always return an empty setinstead of looking up the multixact. (I suppose we could remove theargument in the master branch, but I chose not to do so in this commit).This was broken all along, but the error-facing message appeared firstbecause of commit 8e9a16ab8f7f and was partially fixed in a25c2b7c4db3.This fix, backpatched all the way back to 9.3, goes approximately in thesame direction as a25c2b7c4db3 but should cover all cases.Bug analysis by Andrew Gierth and Álvaro Herrera.A number of public reports match this bug:https://www.postgresql.org/message-id/20140330040029.GY4582@tamriel.snowman.nethttps://www.postgresql.org/message-id/538F3D70.6080902@publicrelay.comhttps://www.postgresql.org/message-id/556439CF.7070109@pscs.co.ukhttps://www.postgresql.org/message-id/SG2PR06MB0760098A111C88E31BD4D96FB3540@SG2PR06MB0760.apcprd06.prod.outlook.comhttps://www.postgresql.org/message-id/20160615203829.5798.4594@wrigleys.postgresql.org1 parent07f6913 commitd372cb1
File tree
5 files changed
+88
-70
lines changed- contrib/pgrowlocks
- src
- backend
- access
- heap
- transam
- utils/time
- include/access
5 files changed
+88
-70
lines changedLines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 |
| - | |
162 |
| - | |
| 161 | + | |
163 | 162 |
| |
164 | 163 |
| |
165 | 164 |
| |
|
Lines changed: 28 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3621 | 3621 |
| |
3622 | 3622 |
| |
3623 | 3623 |
| |
| 3624 | + | |
3624 | 3625 |
| |
3625 | 3626 |
| |
3626 | 3627 |
| |
| |||
5002 | 5003 |
| |
5003 | 5004 |
| |
5004 | 5005 |
| |
5005 |
| - | |
5006 |
| - | |
| 5006 | + | |
5007 | 5007 |
| |
5008 | 5008 |
| |
5009 | 5009 |
| |
| |||
5363 | 5363 |
| |
5364 | 5364 |
| |
5365 | 5365 |
| |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
| 5372 | + | |
| 5373 | + | |
| 5374 | + | |
| 5375 | + | |
| 5376 | + | |
5366 | 5377 |
| |
5367 | 5378 |
| |
5368 | 5379 |
| |
| |||
5921 | 5932 |
| |
5922 | 5933 |
| |
5923 | 5934 |
| |
5924 |
| - | |
5925 | 5935 |
| |
5926 | 5936 |
| |
5927 | 5937 |
| |
5928 | 5938 |
| |
5929 | 5939 |
| |
5930 | 5940 |
| |
5931 |
| - | |
| 5941 | + | |
| 5942 | + | |
5932 | 5943 |
| |
5933 | 5944 |
| |
5934 | 5945 |
| |
| |||
5941 | 5952 |
| |
5942 | 5953 |
| |
5943 | 5954 |
| |
5944 |
| - | |
5945 |
| - | |
5946 |
| - | |
5947 |
| - | |
5948 | 5955 |
| |
5949 |
| - | |
5950 |
| - | |
5951 |
| - | |
| 5956 | + | |
5952 | 5957 |
| |
5953 | 5958 |
| |
5954 | 5959 |
| |
| |||
5990 | 5995 |
| |
5991 | 5996 |
| |
5992 | 5997 |
| |
5993 |
| - | |
5994 |
| - | |
5995 | 5998 |
| |
5996 |
| - | |
| 5999 | + | |
5997 | 6000 |
| |
5998 | 6001 |
| |
5999 | 6002 |
| |
| |||
6535 | 6538 |
| |
6536 | 6539 |
| |
6537 | 6540 |
| |
6538 |
| - | |
6539 | 6541 |
| |
6540 | 6542 |
| |
6541 | 6543 |
| |
6542 | 6544 |
| |
6543 | 6545 |
| |
6544 |
| - | |
6545 |
| - | |
| 6546 | + | |
| 6547 | + | |
| 6548 | + | |
| 6549 | + | |
6546 | 6550 |
| |
6547 | 6551 |
| |
6548 | 6552 |
| |
| |||
6625 | 6629 |
| |
6626 | 6630 |
| |
6627 | 6631 |
| |
6628 |
| - | |
6629 | 6632 |
| |
6630 | 6633 |
| |
6631 | 6634 |
| |
6632 | 6635 |
| |
6633 | 6636 |
| |
6634 |
| - | |
6635 |
| - | |
6636 |
| - | |
| 6637 | + | |
| 6638 | + | |
| 6639 | + | |
| 6640 | + | |
6637 | 6641 |
| |
6638 | 6642 |
| |
6639 | 6643 |
| |
| |||
6765 | 6769 |
| |
6766 | 6770 |
| |
6767 | 6771 |
| |
| 6772 | + | |
| 6773 | + | |
6768 | 6774 |
| |
6769 | 6775 |
| |
6770 | 6776 |
| |
6771 | 6777 |
| |
6772 | 6778 |
| |
6773 | 6779 |
| |
6774 | 6780 |
| |
6775 |
| - | |
6776 | 6781 |
| |
6777 | 6782 |
| |
6778 | 6783 |
| |
6779 |
| - | |
6780 |
| - | |
6781 |
| - | |
| 6784 | + | |
6782 | 6785 |
| |
6783 | 6786 |
| |
6784 | 6787 |
| |
|
Lines changed: 26 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1181 | 1181 |
| |
1182 | 1182 |
| |
1183 | 1183 |
| |
1184 |
| - | |
1185 |
| - | |
1186 |
| - | |
1187 |
| - | |
1188 |
| - | |
1189 |
| - | |
1190 |
| - | |
1191 |
| - | |
1192 |
| - | |
1193 |
| - | |
1194 |
| - | |
1195 |
| - | |
1196 |
| - | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
1197 | 1203 |
| |
1198 | 1204 |
| |
1199 | 1205 |
| |
| |||
1202 | 1208 |
| |
1203 | 1209 |
| |
1204 | 1210 |
| |
1205 |
| - | |
| 1211 | + | |
1206 | 1212 |
| |
1207 | 1213 |
| |
1208 | 1214 |
| |
| |||
1221 | 1227 |
| |
1222 | 1228 |
| |
1223 | 1229 |
| |
1224 |
| - | |
| 1230 | + | |
1225 | 1231 |
| |
1226 | 1232 |
| |
1227 | 1233 |
| |
| |||
1254 | 1260 |
| |
1255 | 1261 |
| |
1256 | 1262 |
| |
1257 |
| - | |
1258 |
| - | |
1259 |
| - | |
1260 |
| - | |
1261 |
| - | |
1262 |
| - | |
1263 |
| - | |
1264 |
| - | |
| 1263 | + | |
1265 | 1264 |
| |
1266 |
| - | |
1267 |
| - | |
1268 |
| - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
1269 | 1268 |
| |
1270 | 1269 |
| |
1271 | 1270 |
| |
| |||
1281 | 1280 |
| |
1282 | 1281 |
| |
1283 | 1282 |
| |
1284 |
| - | |
| 1283 | + | |
1285 | 1284 |
| |
1286 | 1285 |
| |
1287 | 1286 |
| |
|
Lines changed: 8 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
609 | 609 |
| |
610 | 610 |
| |
611 | 611 |
| |
| 612 | + | |
| 613 | + | |
| 614 | + | |
612 | 615 |
| |
613 | 616 |
| |
614 |
| - | |
615 |
| - | |
616 |
| - | |
617 |
| - | |
618 |
| - | |
619 |
| - | |
620 |
| - | |
| 617 | + | |
621 | 618 |
| |
622 | 619 |
| |
623 | 620 |
| |
| |||
1258 | 1255 |
| |
1259 | 1256 |
| |
1260 | 1257 |
| |
1261 |
| - | |
1262 |
| - | |
1263 |
| - | |
| 1258 | + | |
1264 | 1259 |
| |
1265 | 1260 |
| |
1266 | 1261 |
| |
1267 | 1262 |
| |
1268 | 1263 |
| |
1269 | 1264 |
| |
1270 |
| - | |
1271 |
| - | |
1272 |
| - | |
| 1265 | + | |
| 1266 | + | |
1273 | 1267 |
| |
1274 |
| - | |
1275 |
| - | |
| 1268 | + | |
1276 | 1269 |
| |
1277 | 1270 |
| |
1278 | 1271 |
| |
1279 | 1272 |
| |
1280 |
| - | |
1281 | 1273 |
| |
1282 | 1274 |
| |
1283 | 1275 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
217 | 217 |
| |
218 | 218 |
| |
219 | 219 |
| |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
220 | 245 |
| |
221 | 246 |
| |
222 | 247 |
| |
|
0 commit comments
Comments
(0)