Re: Implement waiting for wal lsn replay: reloaded - Mailing list pgsql-hackers

From Xuneng Zhou
Subject Re: Implement waiting for wal lsn replay: reloaded
Date
Msg-id CABPTF7UBdEfyxATWntmCfoJrwB6iPrnhkXO7y_Avmqc2bOn27A@mail.gmail.com
Whole thread Raw
In response to Re: Implement waiting for wal lsn replay: reloaded  (Xuneng Zhou <xunengzhou@gmail.com>)
Responses Re: Implement waiting for wal lsn replay: reloaded
List 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

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: Logical Replication - revisit `is_table_publication` function implementation
Next
From: Tom Lane
Date:
Subject: BF client script runs src/test/modules TAP tests multiple times