Hi,

On 5/19/23 2:29 PM, Bruce Momjian wrote:
On Fri, May 19, 2023 at 09:49:18AM +0200, Drouvot, Bertrand wrote:
Thanks!

"
This adds the function pg_log_standby_snapshot(). TEXT?:
"

My proposal:

This adds the function pg_log_standby_snapshot() to log details of the current 
snapshot
to WAL. If the primary is idle, the slot creation on a standby can take a while.
This function can be used on the primary to speed up the logical slot creation 
on
the standby.

Yes, I got this concept from the commit message, but I am unclear on
what is actually happening so I can clearly explain it.  Slot creation
on the standby needs a snapshot, and that is only created when there is
activity, or happens periodically, and this forces it to happen, or
something?  And what snapshot is this?  The current session's?


It's the snapshot of running transactions (aka the xl_running_xacts WAL record) 
that is used during the
logical slot creation to determine if the logical decoding find a consistent 
state to start with.

On a primary this WAL record is being emitted during the logical slot creation, 
but on a standby
we can't write WAL records (so we are waiting for the primary to emit it).

Outside of logical slot creation, this WAL record is also emitted during 
checkpoint or periodically
by the bgwriter.

What about?

This adds the function pg_log_standby_snapshot() to emit the WAL record that 
contains the list
of running transactions.

If the primary is idle, the logical slot creation on a standby can take a while 
(waiting for this WAL record
to be replayed to determine if the logical decoding find a consistent state to 
start with).

In that case, this new function can be used on the primary to speed up the 
logical slot
creation on the standby.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com


Reply via email to