From eb8bd08dd65c57c46aeb745e962a3f53fc766ad8 Mon Sep 17 00:00:00 2001 From: Kevin Rocker Date: Tue, 11 Aug 2026 22:45:12 +0200 Subject: [PATCH v5 2/2] Assert that vacuum_delay_point() is called only when interruptible. A delay point may sleep and is expected to service query cancel, so it must not be reached while interrupts are held off, e.g. with an LWLock or buffer content lock held. Enforce that in assert-enabled builds so new call sites in locked regions trip the buildfarm rather than silently delaying with interrupts held. Per suggestion from Tom Lane. Author: Kevin Rocker Author: Neil Chen Discussion: https://postgr.es/m/492c6247-43d3-477b-8981-fb0c56767b38%40app.fastmail.com --- src/backend/commands/vacuum.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 38539a6fd3d..7c81ffd6b56 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -2439,6 +2439,13 @@ vacuum_delay_point(bool is_analyze) { double msec = 0; + /* + * A delay point may sleep and must service query cancel, so it cannot be + * reached while interrupts are held off (LWLock or buffer lock held). + */ + Assert(InterruptHoldoffCount == 0); + Assert(CritSectionCount == 0); + /* Always check for interrupts */ CHECK_FOR_INTERRUPTS(); -- 2.54.0