Re: Fix bug of clearing of waitStart in ProcWakeup()
ji xu <thanksgreed@gmail.com>
From: ji xu <thanksgreed@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-24T07:31:06Z
Lists: pgsql-hackers
Chao Li <li.evan.chao@gmail.com> 于2026年2月24日周二 14:29写道:
> Hi,
>
> I just noticed this while reviewing patch [1]. It looks like this is
> caused by a simple typo.
>
> In ProcWakeup():
> ```
> PGPROC *
> ProcWakeup(PGPROC *proc, ProcWaitStatus waitStatus)
> {
> PGPROC *retProc;
>
> /* Proc should be sleeping ... */
> if (proc->links.prev == NULL ||
> proc->links.next == NULL)
> return NULL;
> Assert(proc->waitStatus == PROC_WAIT_STATUS_WAITING);
>
> /* Save next process before we zap the list link */
> retProc = (PGPROC *) proc->links.next;
>
> /* Remove process from wait queue */
> SHMQueueDelete(&(proc->links));
> (proc->waitLock->waitProcs.size)--;
>
> /* Clean up process' state and pass it the ok/fail signal */
> proc->waitLock = NULL;
> proc->waitProcLock = NULL;
> proc->waitStatus = waitStatus;
> pg_atomic_write_u64(&MyProc->waitStart, 0); <== Here, it should
> operate on proc
>
> /* And awaken it */
> SetLatch(&proc->procLatch);
>
> return retProc;
> }
> ```
>
> Since this function is clearly operating on the parameter proc, the only
> statement that touches MyProc looks suspicious. It should reset
> proc->waitStart, not MyProc->waitStart.
>
> As written, it will incorrectly clear the caller’s waitStart instead of
> the awakened backend’s, potentially leaving a stale waitStart value in the
> target PGPROC.
>
> [1]
> https://postgr.es/m/CAHGQGwGw4LhNwOGQT3nbw3uWy8gL94_MB4T39Wfr4_Vgopuovg@mail.gmail.com
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
>
>
>
Hi ,
The fix looks correct to me. I applied it locally and build and "make
check" passed from my side.
Regards,
ji xu
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix ProcWakeup() resetting wrong waitStart field.
- 5d2dec77efaf 14.23 landed
- 74ee3e9e7365 15.18 landed
- b993706787d0 16.14 landed
- f72c92a7f945 17.10 landed
- 0d3be0501784 18.4 landed
- 70f470314cb4 19 (unreleased) landed