information provided about the function in PostgreSQL documentation.

pg_replication_slot_advance ( slot_name name, upto_lsn pg_lsn ) → record ( slot_name name, end_lsn pg_lsn )

Advances the current confirmed position of a replication slot named slot_name. The slot will not be moved backwards, and it will not be moved beyond the current insert location. Returns the name of the slot and the actual position that it was advanced to. The updated slot position information is written out at the next checkpoint if any advancing is done. So in the event of a crash, the slot may return to an earlier position.

Explain what exactly the above lines mentions?

1 Answer 1



For a logical replication slot, this function starts a logical decode and skips any changes before the specified LSN. confirmed_flush position of this slot will be set to the value returned by the function. restart_lsn will also be moved forward if possible.

For a physical replication slot, this function updates restart_lsn.

  • static XLogRecPtr pg_logical_replication_slot_advance(XLogRecPtr moveto) Does the return value of above function is always greater/lesser than ''moveto''...? –
    – manjunath
    Jun 1, 2023 at 7:02
  • Greater or equal.
    – Melkij
    Jun 1, 2023 at 8:02
  • In the definition that i provided from postgresql documentation what is "current confirmed position"....is it confirmed_flush_lsn in logical slot?...and restart_lsn in case of physical slot?
    – manjunath
    Jun 3, 2023 at 6:23
  • yes (some padding for to short comment)
    – Melkij
    Jun 3, 2023 at 7:35
  • how to find exactly the valid moveto_lsn we need to advance our slot??...also what type of change does moveto_lsn points to?........ like row_insert/createTable/updateTable etc? valid moveto_lsn in sense after advancing,our slot should still continue logical decoding with out any error.
    – manjunath
    Jun 5, 2023 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.