Skip to content

Commit 988ffc3

Browse files
Update "don't truncate with failsafe" rationale.
There is a very good (though non-obvious) reason to avoid relation truncation during a VACUUM that has triggered the failsafe mechanism, which was missed before now. Update related comments, so this isn't forgotten. Reported-By: John Naylor <john.naylor@enterprisedb.com> Discussion: https://postgr.es/m/CAFBsxsFiMPxQ-dHZ8tOgktn=+ffeJT3+GinZ4zdOGbmAnCYadA@mail.gmail.com
1 parent 3b0ee7f commit 988ffc3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,8 +2793,13 @@ lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat,
27932793
* an AccessExclusive lock must be replayed on any hot standby, where it can
27942794
* be particularly disruptive.
27952795
*
2796-
* Also don't attempt it if wraparound failsafe is in effect. It's hard to
2797-
* predict how long lazy_truncate_heap will take. Don't take any chances.
2796+
* Also don't attempt it if wraparound failsafe is in effect. The entire
2797+
* system might be refusing to allocate new XIDs at this point. The system
2798+
* definitely won't return to normal unless and until VACUUM actually advances
2799+
* the oldest relfrozenxid -- which hasn't happened for target rel just yet.
2800+
* If lazy_truncate_heap attempted to acquire an AccessExclusiveLock to
2801+
* truncate the table under these circumstances, an XID exhaustion error might
2802+
* make it impossible for VACUUM to fix the underlying XID exhaustion problem.
27982803
* There is very little chance of truncation working out when the failsafe is
27992804
* in effect in any case. lazy_scan_prune makes the optimistic assumption
28002805
* that any LP_DEAD items it encounters will always be LP_UNUSED by the time

0 commit comments

Comments
 (0)