From 8b5f34b9b4468a55d06b98401e13fa01562748b0 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Fri, 16 Oct 2026 11:08:36 +0000 Subject: [PATCH v1 2/2] aio: Hold interrupts earlier in I/O workers errfinish() checks for interrupts after emitting a non-error message, and I/O workers exit when processing a die interrupt. IoWorkerMain() emitted the DEBUG4 "processing IO" message before holding interrupts, so a SIGINT received then made the worker exit without completing the IO it had dequeued. Backends waiting for that IO then hung. Hold interrupts before emitting the message. This is only reachable when DEBUG4 messages from I/O workers are logged. Backpatch-through: 18 --- src/backend/storage/aio/method_worker.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/backend/storage/aio/method_worker.c b/src/backend/storage/aio/method_worker.c index c9e17bde358..743d217a536 100644 --- a/src/backend/storage/aio/method_worker.c +++ b/src/backend/storage/aio/method_worker.c @@ -889,17 +889,19 @@ IoWorkerMain(const void *startup_data, size_t startup_data_len) error_ioh = ioh; errcallback.arg = ioh; - pgaio_debug_io(DEBUG4, ioh, - "worker %d processing IO", - MyIoWorkerId); - /* * Prevent interrupts between pgaio_io_reopen() and * pgaio_io_perform_synchronously() that otherwise could lead to - * the FD getting closed in that window. + * the FD getting closed in that window. Also hold them while + * logging, as ereport() can process a die interrupt and exit + * without completing the IO. */ HOLD_INTERRUPTS(); + pgaio_debug_io(DEBUG4, ioh, + "worker %d processing IO", + MyIoWorkerId); + /* * It's very unlikely, but possible, that reopen fails. E.g. due * to memory allocations failing or file permissions changing or -- 2.43.0