From af3b8a2d696a2e877f95fa357bb5cd743a077ae4 Mon Sep 17 00:00:00 2001 From: alterego655 <824662526@qq.com> Date: Fri, 24 Jul 2026 16:37:20 +0800 Subject: [PATCH v4 4/5] Clarify LSN waiter cleanup after wakeup WaitLSNWakeup() can be called by several processes, not only the startup process. Update the cleanup comment to explain that another process may remove the waiter before waking it and that inHeap prevents double deletion. --- src/backend/access/transam/xlogwait.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlogwait.c b/src/backend/access/transam/xlogwait.c index 6d19343b2a5..763fd46bf48 100644 --- a/src/backend/access/transam/xlogwait.c +++ b/src/backend/access/transam/xlogwait.c @@ -523,9 +523,11 @@ WaitForLSN(WaitLSNType lsnType, XLogRecPtr targetLSN, int64 timeout) } /* - * Delete our process from the shared memory heap. We might already be - * deleted by the startup process. The 'inHeap' flags prevents us from - * the double deletion. + * Ensure that we are no longer registered before returning. A progress + * wakeup removes the waiter before setting its latch, but timeout, recovery + * end, or an unrelated latch wakeup can leave it in the heap. + * The inHeap flag lets deleteLSNWaiter() distinguish these cases and avoid + * double deletion. */ deleteLSNWaiter(lsnType); -- 2.51.0