Fix how flush_pos is compared to commit_lsn. #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we logically replicate the message with LSN equal to exactly X, we need to wait for
flush_pos
of other replicas to become strictly greater than X, not greater or equal.Both
restart_lsn
andconfirmed_flush
represent the oldest LSN that must still be kept so it can still be replicated. That means that it might NOT yet be replicated.--
I made some trivial experiment to check how
pg_failover_slots.standby_slot_names
behaves and noticed that my logical replica always gets one extra record when the physical replica becomes unavailable. With this fix it works as expected: logical replica is never delayed more then necessary, but no records that were not replicated to physical replica are replicated to the logical one.