From 52c802a00572b382ee0203b0038dbe509e4ecb72 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Wed, 22 Feb 2023 12:26:01 -0500 Subject: [PATCH v6 3/6] use shared buffers when failsafe active --- doc/src/sgml/config.sgml | 8 +++++--- src/backend/access/heap/vacuumlazy.c | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index e5c41cc6c6..fca38a4514 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -9291,9 +9291,11 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; the failsafe to trigger during any VACUUM. - When the failsafe is triggered, any cost-based delay that is - in effect will no longer be applied, and further non-essential - maintenance tasks (such as index vacuuming) are bypassed. + When the failsafe is triggered, any cost-based delay that is in effect + will no longer be applied, further non-essential maintenance tasks + (such as index vacuuming) are bypassed, and any Buffer Access Strategy + in use will be abandoned and the vacuum will be free to use as many + shared buffers as it needs to finish vacuuming the table. The default is 1.6 billion transactions. Although users can diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 8f14cf85f3..3de7976cf6 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -2622,6 +2622,13 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel) if (unlikely(vacuum_xid_failsafe_check(&vacrel->cutoffs))) { vacrel->failsafe_active = true; + /* + * Abandon use of a buffer access strategy when entering failsafe mode, + * as completing the ongoing VACUUM is our top priority. + * Assume the caller who allocated the memory for the + * BufferAccessStrategy object will free it. + */ + vacrel->bstrategy = NULL; /* Disable index vacuuming, index cleanup, and heap rel truncation */ vacrel->do_index_vacuuming = false; -- 2.37.2