pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chao Li <li.evan.chao@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: ji xu <thanksgreed@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Fix bug of clearing of waitStart in ProcWakeup()
Date: Wed, 25 Feb 2026 06:03:14 +0800
Message-ID: <2058F900-0706-4B46-A398-54FDABFD29F7@gmail.com> (raw)
In-Reply-To: <CAHGQGwHJGgZS8iiJVUse1QraMXmYzo+5vw4jd-0MQe5h9pyWXg@mail.gmail.com>
References: <537BD852-EC61-4D25-AB55-BE8BE46D07D7@gmail.com>
	<CANWi6YNc+qC7O086svzf1jO=udJNA8+aa0gqp2BS7tyKB7dLaA@mail.gmail.com>
	<CAHGQGwHJGgZS8iiJVUse1QraMXmYzo+5vw4jd-0MQe5h9pyWXg@mail.gmail.com>



> On Feb 24, 2026, at 23:41, Fujii Masao <masao.fujii@gmail.com> wrote:
> 
> On Tue, Feb 24, 2026 at 4:31 PM ji xu <thanksgreed@gmail.com> wrote:
>> 
>> 
>> Chao Li <li.evan.chao@gmail.com> 于2026年2月24日周二 14:29写道:
>>> 
>>> 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.
> 
> Thanks for the report!
> 

I just realized that I forgot to attach the patch file. Anyway, that’s just a one-line change.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

v1-0001-Fix-bug-of-clearing-of-waitStart-in-ProcWakeup.patch (application/octet-stream, 1.1K) download From 5a741a41f675a8cff11cdbb20c819e4853ed1499 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" <lic@highgo.com> Date: Tue, 24 Feb 2026 14:11:24 +0800 Subject: [PATCH v1] Fix bug of clearing of waitStart in ProcWakeup() ProcWakeup() incorrectly resets MyProc->waitStart instead of the waitStart field of the process being awakened. Fix by resetting proc->waitStart, which corresponds to the PGPROC being removed from the wait queue. This looks like oversight of 46d6e5f. Author: Chao Li <lic@highgo.com> Reviewed-by: Discussion: https://postgr.es/m/ --- 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 e2f34075d39..771b006b522 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -1715,7 +1715,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); -- 2.50.1 (Apple Git-155) =

view thread (10+ messages)  latest in thread

Message-ID: <2058F900-0706-4B46-A398-54FDABFD29F7@gmail.com>
Permalink:  ../2058F900-0706-4B46-A398-54FDABFD29F7@gmail.com/
Also on:    postgresql.org/message-id/2058F900-0706-4B46-A398-54FDABFD29F7@gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: li.evan.chao@gmail.com, masao.fujii@gmail.com, thanksgreed@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Fix bug of clearing of waitStart in ProcWakeup()
  In-Reply-To: <2058F900-0706-4B46-A398-54FDABFD29F7@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox