From e0b995e5b23116450646fd1004db4bdcdbe213e4 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Thu, 15 Oct 2026 14:09:10 -0700 Subject: [PATCH] Avoid dangling shared memory pointers in parallel vacuum. When a parallel vacuum failed, the leader's VacuumSharedCostBalance and VacuumActiveNWorkers kept pointing into the parallel vacuum's DSM segment, which is gone after the abort, until the next vacuum in the same process reset them. Nothing in the current code reads them in the meantime, but it's better not to leave them dangling. Reset them at the end of vacuum(), as we already do at its start. No backpatch, as this doesn't fix any live problem. Author: Bharath Rupireddy Reviewed-by: Masahiko Sawada Discussion: https://postgr.es/m/CALj2ACW3OY7Ex-2-aits7yhRciH20r12DHcCNf+exuweR1FcMw@mail.gmail.com --- src/backend/commands/vacuum.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index a257dd8d21e..c7595d59bb2 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -684,6 +684,9 @@ vacuum(List *relations, const VacuumParams *params, BufferAccessStrategy bstrate VacuumCostActive = false; VacuumFailsafeActive = false; VacuumCostBalance = 0; + VacuumCostBalanceLocal = 0; + VacuumSharedCostBalance = NULL; + VacuumActiveNWorkers = NULL; } PG_END_TRY();