forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite5ed873
committed
Fix a possibility of logical replication slot's restart_lsn going backwards.
Previously LogicalIncreaseRestartDecodingForSlot() accidentallyaccepted any LSN as the candidate_lsn and candidate_valid after therestart_lsn of the replication slot was updated, so it potentiallycaused the restart_lsn to move backwards.A scenario where this could happen in logical replication is: after alogical replication restart, based on previous candidate_lsn andcandidate_valid values in memory, the restart_lsn advances uponreceiving a subscriber acknowledgment. Then, logical decoding restartsfrom an older point, setting candidate_lsn and candidate_valid basedon an old RUNNING_XACTS record. Subsequent subscriber acknowledgmentsthen update the restart_lsn to an LSN older than the current value.In the reported case, after WAL files were removed by a checkpoint,the retreated restart_lsn prevented logical replication fromrestarting due to missing WAL segments.This change essentially modifies the 'if' condition to 'else if'condition within the function. The previous code had an asymmetry inthis regard compared to LogicalIncreaseXminForSlot(), which doesalmost the same thing for different fields.The WAL removal issue was reported by Hubert Depesz Lubaczewski.Backpatch to all supported versions, since the bug exists since 9.4where logical decoding was introduced.Reviewed-by: Tomas Vondra, Ashutosh Bapat, Amit KapilaDiscussion:https://postgr.es/m/Yz2hivgyjS1RfMKs%40depesz.comDiscussion:https://postgr.es/m/85fff40e-148b-4e86-b921-b4b846289132%40vondra.meBackpatch-through: 131 parentb69bdce commite5ed873
1 file changed
+3
-1
lines changedLines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1774 | 1774 |
| |
1775 | 1775 |
| |
1776 | 1776 |
| |
| 1777 | + | |
1777 | 1778 |
| |
1778 | 1779 |
| |
1779 | 1780 |
| |
| |||
1784 | 1785 |
| |
1785 | 1786 |
| |
1786 | 1787 |
| |
| 1788 | + | |
1787 | 1789 |
| |
1788 | 1790 |
| |
1789 | 1791 |
| |
| |||
1794 | 1796 |
| |
1795 | 1797 |
| |
1796 | 1798 |
| |
1797 |
| - | |
| 1799 | + | |
1798 | 1800 |
| |
1799 | 1801 |
| |
1800 | 1802 |
| |
|
0 commit comments
Comments
(0)