postgres.git / summary / log / commit / refs

commit    74ee3e9e73656497d0bbf57ff6d839b37feefb09
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Wed Feb 25 23:46:12 2026 +0000
First released in: 14.23, 15.18, 16.14, 17.10, 18.4

    Fix ProcWakeup() resetting wrong waitStart field.
    
    Previously, when one process woke another that was waiting on a lock,
    ProcWakeup() incorrectly cleared its own waitStart field (i.e.,
    MyProc->waitStart) instead of that of the process being awakened.
    As a result, the awakened process retained a stale lock-wait start timestamp.
    
    This did not cause user-visible issues. pg_locks.waitstart was reported as
    NULL for the awakened process (i.e., when pg_locks.granted is true),
    regardless of the waitStart value.
    
    This bug was introduced by commit 46d6e5f56790.
    
    This commit fixes this by resetting the waitStart field of the process
    being awakened in ProcWakeup().
    
    Backpatch to all supported branches.
    
    Reported-by: Chao Li <li.evan.chao@gmail.com>
    Author: Chao Li <li.evan.chao@gmail.com>
    Reviewed-by: ji xu <thanksgreed@gmail.com>
    Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
    Discussion: https://postgr.es/m/537BD852-EC61-4D25-AB55-BE8BE46D07D7@gmail.com
    Backpatch-through: 14


src/backend/storage/lmgr/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 6fbbf5c1657..93c4324534b 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -1695,7 +1695,7 @@ ProcWakeup(PGPROC *proc, ProcWaitStatus waitStatus) proc->waitLock = NULL; proc->waitProcLock = NULL; proc->waitStatus = waitStatus; - pg_atomic_write_u64(&MyProc->waitStart, 0); + pg_atomic_write_u64(&proc->waitStart, 0); /* And awaken it */ SetLatch(&proc->procLatch); [parent: 7e788a585a6c]