Re: Improve WAIT FOR read-your-writes consistency doc

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improve WAIT FOR read-your-writes consistency doc
Date: 2026-09-09 07:52:52
Message-ID: CABPTF7Xr0+rVkptmihChYkH+vXBEbmrNn3x_sLr5S0cHMc-8Tw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Sami,

On Wed, Sep 9, 2026 at 5:42 AM Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> wrote:

> The WAIT FOR docs say that "The standby_replay mode waits for the LSN to be
> replayed (applied to the database), which is useful to achieve
> read-your-writes
> consistency while using an async replica for reads and the primary for
> writes."
>
> I think that needs one more caveat.
>
> WAIT FOR success does not guarantee read-your-writes if the supplied LSN
> is before the transaction's COMMIT record.
>
> Maybe the last sentence should be qualified with:
>
> " .... the primary for writes, provided that the target LSN was
> captured after COMMIT on the primary."
>
> This may be obvious to users of this feature, but perhaps worth being
> more explicit about it.
>
> Thoughts?

Thanks for raising this! I agree this may need to be harnessed. If we
change this line, we might also want to modify the
read-your-writes-consistency chapter.
<sect2 id="read-your-writes-consistency">
<title>Read-Your-Writes Consistency</title>

I am also wondering whether a example like this is helpful, though it is
somehow duplicated with the existing one:
postgres=# BEGIN;
BEGIN
postgres=*# UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama';
UPDATE 100
postgres=*# COMMIT;
COMMIT
postgres=# SELECT pg_current_wal_insert_lsn();

--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2026-09-09 08:04:04 Re: [PATCH] Allow bare library names for non-superuser LOAD
Previous Message Alexander Pyhalov 2026-09-09 07:51:46 Parameterized append subpaths