A out of date comment of WaitForWALToBecomeAvailable

Started by Andy Fan8 months ago6 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t53213
psql -h localhost -U postgres

Built from patchset v3 (message #3), July 27, 2026 at 04:27 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t53213_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t53213_3 && git checkout t53213_3

Patchset v3 (message #3) is on t53213_3

Jump to latest
#1Andy Fan
zhihui.fan1213@gmail.com

Hi,

The following comment looks out of date now. should we fix it as following?

  *
- * If the record is not immediately available, the function returns false
+ * If the record is not immediately available, the function returns XLREAD_FAIL
  * if we're not in standby mode. In standby mode, waits for it to become
  * available.
  *
..
static XLogPageReadResult
WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, ..)

Thanks

#2Michael Paquier
michael@paquier.xyz
In reply to: Andy Fan (#1)
Re: A out of date comment of WaitForWALToBecomeAvailable

On Fri, Jan 30, 2026 at 10:29:41AM +0800, Andy Fan wrote:

The following comment looks out of date now. should we fix it as following?

Yes, the code returns XLREAD_FAIL is we cannot find a record when not
in standby mode. Thanks for the report.
--
Michael

#3Andy Fan
zhihui.fan1213@gmail.com
In reply to: Michael Paquier (#2)
Re:Re: A out of date comment of WaitForWALToBecomeAvailable

At 2026-01-30 13:13:37, "Michael Paquier" <michael@paquier.xyz> wrote:

Hi,

On Fri, Jan 30, 2026 at 10:29:41AM +0800, Andy Fan wrote:

The following comment looks out of date now. should we fix it as following?

Yes, the code returns XLREAD_FAIL is we cannot find a record when not
in standby mode. Thanks for the report.

Thanks for double check. patch attached.

Attachments:

t53213_3
v1-0001-Fix-out-of-date-comment-in-WaitForWALToBecomeAvai.patchapplication/octet-stream; name=v1-0001-Fix-out-of-date-comment-in-WaitForWALToBecomeAvai.patch; x-cm-securityLevel=0Download+1-2
#4Xuneng Zhou
xunengzhou@gmail.com
In reply to: Andy Fan (#3)
Re: Re: A out of date comment of WaitForWALToBecomeAvailable

Hi Andy,

Thanks for the patch.

On Fri, Jan 30, 2026 at 6:23 PM Andy Fan <zhihuifan1213@163.com> wrote:

At 2026-01-30 13:13:37, "Michael Paquier" <michael@paquier.xyz> wrote:

Hi,

On Fri, Jan 30, 2026 at 10:29:41AM +0800, Andy Fan wrote:

The following comment looks out of date now. should we fix it as following?

Yes, the code returns XLREAD_FAIL is we cannot find a record when not
in standby mode. Thanks for the report.

Thanks for double check. patch attached.

WaitForWALToBecomeAvailable can also return XLREAD_WOULDBLOCK when the
caller set nonblocking. The comment only talks about XLREAD_FAIL vs
“waits in standby,” so it still doesn’t describe that third outcome.
That omission pre-dates this patch, should we expand the comment
mention the nonblocking case as well?

--
Best,
Xuneng

#5Michael Paquier
michael@paquier.xyz
In reply to: Xuneng Zhou (#4)
Re: Re: A out of date comment of WaitForWALToBecomeAvailable

On Mon, Feb 02, 2026 at 10:37:43AM +0800, Xuneng Zhou wrote:

WaitForWALToBecomeAvailable can also return XLREAD_WOULDBLOCK when the
caller set nonblocking. The comment only talks about XLREAD_FAIL vs
“waits in standby,” so it still doesn’t describe that third outcome.
That omission pre-dates this patch, should we expand the comment
mention the nonblocking case as well?

The outcome related to XLREAD_WOULDBLOCK is implied in the last
sentence of the comment block standing at the top of the function,
which seems OK to me.
--
Michael

#6Andy Fan
zhihui.fan1213@gmail.com
In reply to: Michael Paquier (#5)
Re: A out of date comment of WaitForWALToBecomeAvailable

Hi All,

[[PGP Signed Part:Undecided]]
On Mon, Feb 02, 2026 at 10:37:43AM +0800, Xuneng Zhou wrote:

WaitForWALToBecomeAvailable can also return XLREAD_WOULDBLOCK when the
caller set nonblocking. The comment only talks about XLREAD_FAIL vs
“waits in standby,” so it still doesn’t describe that third outcome.
That omission pre-dates this patch, should we expand the comment
mention the nonblocking case as well?

The outcome related to XLREAD_WOULDBLOCK is implied in the last
sentence of the comment block standing at the top of the function,
which seems OK to me.

Thank you for the double check, I personally prefer to keep
XLREAD_WOULDBLOCK as it it.

--
Best Regards
Andy Fan