From 87a4e6438f5d5a51f4844e83141319bac4b26786 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Tue, 15 Sep 2026 07:23:59 +0000 Subject: [PATCH v5 4/4] Clear the REPACK message flag when there is nothing to do. Previously, ProcessRepackMessages() returned without clearing RepackMessagePending when there was no decoding worker to read messages from. The worker signals the backend as it exits, and by the time the backend handles that signal it has usually dropped the worker already, so the flag stayed set. Every later ProcessInterrupts() then called the function for nothing until the session ran REPACK again. Fix this by clearing the flag before that check, so that it always tells whether there are messages to process. Nothing is broken today, because the function has nothing to do without a worker, but the flag should not claim work that is not there. Backpatch to 19, where REPACK CONCURRENTLY was introduced. Author: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACVAxA9HxvFe8HSspTJ-UO4Aoz%3DkuQdZBeLrod0gqUxH3g%40mail.gmail.com Backpatch-through: 19 --- src/backend/commands/repack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c index 9c51b945a8a..d3bb296df25 100644 --- a/src/backend/commands/repack.c +++ b/src/backend/commands/repack.c @@ -4077,6 +4077,9 @@ ProcessRepackMessages(void) MemoryContext oldcontext; static MemoryContext hpm_context = NULL; + /* Reset the flag saying there are messages to process. */ + RepackMessagePending = false; + /* * Nothing to do if we haven't launched the worker yet or have already * terminated it. Stopping the worker detaches the error message queue @@ -4109,9 +4112,6 @@ ProcessRepackMessages(void) oldcontext = MemoryContextSwitchTo(hpm_context); - /* OK to process messages. Reset the flag saying there are more to do. */ - RepackMessagePending = false; - /* * Read as many messages as we can from the worker, but stop when either * (1) the worker's error message queue goes away, which can happen if we -- 2.47.3