On Mon, Aug 11, 2025 at 9:44 AM Amit Kapila <amit.kapil...@gmail.com> wrote: > How do you advance the origin? Did you use > pg_replication_origin_advance()? > If so, you should be aware that it > can be used for initial setup; see comment in that API code...
No, we don't use pg_replication_origin_advance(). We use pg_replication_origin_xact_setup() instead as I mentioned before. Each worker does the following: 1. Sets up its own replication-origin session with pg_replication_origin_session_setup() (using the master process PID). 2. Applies changes inside transactions. 3. Right before commit, calls pg_replication_origin_xact_setup(lsn, commit_timestamp). 4. Commits only if everything succeeded, so the origin only advances on a real commit. That way, the origin LSN moves forward only when the transaction is actually committed. If something fails or the process crashes, the origin stays at the last successful commit, and on restart we replay from the correct spot. It's safer than advancing the origin without knowing the transaction made it to disk. So the issue you described is not relevant for our implementation.