Re: Fix bug of clearing of waitStart in ProcWakeup()

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: ji xu <thanksgreed(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix bug of clearing of waitStart in ProcWakeup()
Date: 2026-02-24 15:41:03
Message-ID: CAHGQGwHJGgZS8iiJVUse1QraMXmYzo+5vw4jd-0MQe5h9pyWXg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 24, 2026 at 4:31 PM ji xu <thanksgreed(at)gmail(dot)com> wrote:
>
>
> Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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!

You’re right. This leaves proc->waitStart unreset for a backend that has
woken up from a lock wait. In practice this doesn't seem to cause
user-visible issues, since pg_locks.waitstart is reported as NULL
when pg_locks.granted is true, regardless of proc->waitStart.

That said, the behavior is incorrect, so I'm feeling inclined to backpatch
a fix. Thoughts?

> The fix looks correct to me. I applied it locally and build and "make check" passed from my side.

Sounds good to me.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2026-02-24 15:55:20 Re: pgsql: libpq: Grease the protocol by default
Previous Message 陈宗志 2026-02-24 15:27:35 Re: [PROPOSAL] Doublewrite Buffer as an alternative torn page protection to Full Page Write