Hi,
On Wed, Apr 3, 2024 at 4:58 AM Alexander Korotkov
<akorotkov@postgresql.org> wrote:
>
> Implement pg_wal_replay_wait() stored procedure
>
> pg_wal_replay_wait() is to be used on standby and specifies waiting for
> the specific WAL location to be replayed before starting the transaction.
> This option is useful when the user makes some data changes on primary and
> needs a guarantee to see these changes on standby.
>
> The queue of waiters is stored in the shared memory array sorted by LSN.
> During replay of WAL waiters whose LSNs are already replayed are deleted from
> the shared memory array and woken up by setting of their latches.
>
> pg_wal_replay_wait() needs to wait without any snapshot held. Otherwise,
> the snapshot could prevent the replay of WAL records implying a kind of
> self-deadlock. This is why it is only possible to implement
> pg_wal_replay_wait() as a procedure working in a non-atomic context,
> not a function.
>
> Catversion is bumped.
>
mamba complaints the build error[1]:
waitlsn.c: In function 'WaitForLSN':
waitlsn.c:275:24: error: 'endtime' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
275 | delay_ms = (endtime - GetCurrentTimestamp()) / 1000;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Regards,
[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mamba&dt=2024-04-03%2005%3A33%3A24
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com