postgresqllogical-replicationpglogical

When does pg_replication_slot_advance(slot_name name, upto_lsn pg_lsn) function is used?


1Q Is it called by postgres internally or can it be called by an user. 2Q If it is called by user, then how does he find valid moveto_lsn point in wal records so that after advancing the logical slot...logical decoding continues without error. 3Q If it is called by postgresql internally in what specific use case it is called.

I have read postgres documentation but didn't find proper answers


Solution

  • 1.It can be called by super user of the database.

    2.you have to provide proper lsn which is greater than current confirmed_flush lsn of slot.

    3.Main purpose of creating this function is to advance the slot without sending the changes to client.Current use case is,it can be used in standby servers to advance the state of slot based on confirmed_flush lsn of same slot present in master server.This indirectly helps in resuming logical decoding from standby.