From d5f15d50a8fdc3e32033358c15cdc556327f070b Mon Sep 17 00:00:00 2001 From: alterego655 <824662526@qq.com> Date: Fri, 24 Jul 2026 16:37:20 +0800 Subject: [PATCH v7 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlogwait.c b/src/backend/access/transam/xlogwait.c index 5ff1d4fcd70..b82f64df65a 100644 --- a/src/backend/access/transam/xlogwait.c +++ b/src/backend/access/transam/xlogwait.c @@ -524,9 +524,10 @@ 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. + * A progress waker, such as the startup process during WAL replay, may + * already have removed this waiter through WaitLSNWakeup() before setting + * its latch. The inHeap flag makes this cleanup safe whether or not the + * entry remains in the heap. */ deleteLSNWaiter(lsnType); -- 2.55.0