From 3383a88c0b817244bf19c05ab346291ce0339e0c Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Wed, 22 Feb 2023 12:26:01 -0500 Subject: [PATCH v8 3/6] use shared buffers when failsafe active --- doc/src/sgml/config.sgml | 8 +++++--- src/backend/access/heap/vacuumlazy.c | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index fcb53c6997..7b8cf624dc 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -9319,9 +9319,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 ae628d747d..0be41640be 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -2623,6 +2623,14 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel) { 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; vacrel->do_index_cleanup = false; -- 2.37.2