- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit83c39a1
committed
Ensure vacuum removes all visibly dead tuples older than OldestXmin
If vacuum fails to remove a tuple with xmax older thanVacuumCutoffs->OldestXmin and younger than GlobalVisState->maybe_needed,it may attempt to freeze the tuple's xmax and then ERROR out inpre-freeze checks with "cannot freeze committed xmax".Fix this by having vacuum always remove tuples older than OldestXmin.It is possible for GlobalVisState->maybe_needed to precede OldestXmin ifmaybe_needed is forced to go backward while vacuum is running. This canhappen if a disconnected standby with a running transaction older thanVacuumCutoffs->OldestXmin reconnects to the primary after vacuuminitially calculates GlobalVisState and OldestXmin.In back branches starting with 14, the first version usingGlobalVisState, failing to remove tuples older than OldestXmin duringpruning caused vacuum to infinitely loop in lazy_scan_prune(), asinvestigated on this [1] thread. After1ccc1e0 removed the retry loopin lazy_scan_prune() and stopped comparing tuples to OldestXmin, thehang could no longer happen, but we could still attempt to freeze deadtuples with xmax older than OldestXmin -- resulting in an ERROR.Fix this by always removing dead tuples with xmax older thanVacuumCutoffs->OldestXmin. This is okay because the standby won't replaythe tuple removal until the tuple is removable. Thus, the worst that canhappen is a recovery conflict.[1]https://postgr.es/m/20240415173913.4zyyrwaftujxthf2%40awork3.anarazel.de#1b216b7768b5bd577a3d3d51bd5aadeeBack-patch through 14Author: Melanie PlagemanReviewed-by: Peter Geoghegan, Robert Haas, Andres Freund, Heikki Linnakangas, and Noah MischDiscussion:https://postgr.es/m/CAAKRu_bDD7oq9ZwB2OJqub5BovMG6UjEYsoK2LVttadjEqyRGg%40mail.gmail.com1 parent5784a49 commit83c39a1
2 files changed
+29
-8
lines changedLines changed: 22 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
325 | 325 |
| |
326 | 326 |
| |
327 | 327 |
| |
| 328 | + | |
| 329 | + | |
328 | 330 |
| |
329 | 331 |
| |
330 | 332 |
| |
| |||
922 | 924 |
| |
923 | 925 |
| |
924 | 926 |
| |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
925 | 946 |
| |
926 |
| - | |
| 947 | + | |
927 | 948 |
| |
928 | 949 |
| |
929 | 950 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
438 | 438 |
| |
439 | 439 |
| |
440 | 440 |
| |
441 |
| - | |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
448 | 448 |
| |
449 | 449 |
| |
450 | 450 |
| |
|
0 commit comments
Comments
(0)