Consider triggering VACUUM failsafe during scan.
authorPeter Geoghegan <pg@bowt.ie>
Tue, 25 May 2021 00:14:02 +0000 (17:14 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Tue, 25 May 2021 00:14:02 +0000 (17:14 -0700)
commitc242baa4a831ac2e7dcaec85feb410aefa3a996e
tree6e3348f00920de9bce9e872e83a6ad8831c324e8
parent713a431c781fbfe1a22fae4991836077f0f4c513
Consider triggering VACUUM failsafe during scan.

The wraparound failsafe mechanism added by commit 1e55e7d1 handled the
one-pass strategy case (i.e. the "table has no indexes" case) by adding
a dedicated failsafe check.  This made up for the fact that the usual
one-pass checks inside lazy_vacuum_all_indexes() cannot ever be reached
during a one-pass strategy VACUUM.

This approach failed to account for two-pass VACUUMs that opt out of
index vacuuming up-front.  The INDEX_CLEANUP off case in the only case
that works like that.

Fix this by performing a failsafe check every 4GB during the first scan
of the heap, regardless of the details of the VACUUM.  This eliminates
the special case, and will make the failsafe trigger more reliably.

Author: Peter Geoghegan <pg@bowt.ie>
Reported-By: Andres Freund <andres@anarazel.de>
Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/20210424002921.pb3t7h6frupdqnkp@alap3.anarazel.de
src/backend/access/heap/vacuumlazy.c