| From: | Xuneng Zhou <xunengzhou(at)gmail(dot)com> |
|---|---|
| To: | Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, jian he <jian(dot)universality(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> |
| Subject: | Re: Implement waiting for wal lsn replay: reloaded |
| Date: | 2026-04-08 04:59:03 |
| Message-ID: | CABPTF7UBdEfyxATWntmCfoJrwB6iPrnhkXO7y_Avmqc2bOn27A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> > Patch 0001 looks OK for me.
> > Regarding patch 0002. Changes made for GetCurrentLSNForWaitType()
> > looks reliable for me. PerformWalRecovery() sets replayed positions
> > before starting recovery, and in turn before standby can accept
> > connections. So, changes to WalReceiverMain() don't look necessary to
> > me.
>
> Yeah, GetCurrentLSNForWaitType seems to be the right place to place
> the fix. Please see the attached patch 2.
>
> I also noticed another relevent problem:
>
> During pure archive recovery (no walreceiver), a backend that issues
> 'WAIT FOR LSN ... MODE 'standby_write' with a target ahead of the
> current replay position will sleep forever; the startup process
> replays past the target but only wakes 'STANDBY_REPLAY' waiters.
>
> This also affects mixed scenarios: the walreceiver may lag behind
> replay (e.g., archive restore has delivered WAL faster than
> streaming), so a 'standby_write' waiter could be waiting on WAL that
> replay has already consumed.
>
> I will write a patch to address this soon.
>
Here is the patch.
--
Best,
Xuneng
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0003-Wake-standby_write-standby_flush-waiters-from-the.patch | application/octet-stream | 5.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-04-08 05:00:51 | BF client script runs src/test/modules TAP tests multiple times |
| Previous Message | Peter Smith | 2026-04-08 04:53:33 | Re: Logical Replication - revisit `is_table_publication` function implementation |