forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite7ea2fa
committed
Fix corner-case failure to detect improper timeline switch.
rescanLatestTimeLine() contains a guard against switching toa timeline that forked off from the current one prior to thecurrent recovery point, but that guard does not work if thetimeline switch occurs before the first WAL recod (which mustbe the checkpoint record) is read. Without this patch, animproper timeline switch is therefore possible in such cases.This happens because rescanLatestTimeLine() relies on the globalvariable EndRecPtr to understand the current position of WALreplay. However, EndRecPtr at this point in the code containsthe endpoint of the last-replayed record, not the startpoint orendpoint of the record being replayed now. Thus, before anyrecords have been replayed, it's zero, which causes the sanitycheck to always pass.To fix, pass down the correct timeline explicitly. TheEndRecPtr value we want is the one from the xlogreader, whichwill be the starting position of the record we're about totry to read, rather than the global variable, which is theending position of the last record we successfully read.They're usually the same, but not in the corner case describedhere.No back-patch, because in v14 and earlier branhes, we were usingthe wrong TLI here as well as the wrong LSN. In master, that wasfixed by commit4a92a1c, butthat and it's prerequisite patches are too invasive toback-patch for such a minor issue.Patch by me, reviewed by Amul Sul.Discussion:http://postgr.es/m/CA+Tgmoao96EuNeSPd+hspRKcsCddu=b1h-QNRuKfY8VmfNQdfg@mail.gmail.com1 parentf79962d commite7ea2fa
1 file changed
+16
-9
lines changedLines changed: 16 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
924 | 924 |
| |
925 | 925 |
| |
926 | 926 |
| |
927 |
| - | |
| 927 | + | |
| 928 | + | |
928 | 929 |
| |
929 | 930 |
| |
930 | 931 |
| |
| |||
946 | 947 |
| |
947 | 948 |
| |
948 | 949 |
| |
949 |
| - | |
| 950 | + | |
| 951 | + | |
950 | 952 |
| |
951 | 953 |
| |
952 | 954 |
| |
| |||
4620 | 4622 |
| |
4621 | 4623 |
| |
4622 | 4624 |
| |
4623 |
| - | |
| 4625 | + | |
4624 | 4626 |
| |
4625 | 4627 |
| |
4626 | 4628 |
| |
| |||
4671 | 4673 |
| |
4672 | 4674 |
| |
4673 | 4675 |
| |
4674 |
| - | |
| 4676 | + | |
4675 | 4677 |
| |
4676 | 4678 |
| |
4677 | 4679 |
| |
4678 | 4680 |
| |
4679 | 4681 |
| |
4680 |
| - | |
| 4682 | + | |
4681 | 4683 |
| |
4682 | 4684 |
| |
4683 | 4685 |
| |
| |||
12473 | 12475 |
| |
12474 | 12476 |
| |
12475 | 12477 |
| |
12476 |
| - | |
| 12478 | + | |
| 12479 | + | |
12477 | 12480 |
| |
12478 | 12481 |
| |
12479 | 12482 |
| |
| |||
12626 | 12629 |
| |
12627 | 12630 |
| |
12628 | 12631 |
| |
| 12632 | + | |
| 12633 | + | |
| 12634 | + | |
| 12635 | + | |
12629 | 12636 |
| |
12630 | 12637 |
| |
12631 | 12638 |
| |
| |||
12638 | 12645 |
| |
12639 | 12646 |
| |
12640 | 12647 |
| |
12641 |
| - | |
| 12648 | + | |
12642 | 12649 |
| |
12643 | 12650 |
| |
12644 | 12651 |
| |
| |||
12761 | 12768 |
| |
12762 | 12769 |
| |
12763 | 12770 |
| |
12764 |
| - | |
| 12771 | + | |
12765 | 12772 |
| |
12766 | 12773 |
| |
12767 | 12774 |
| |
| |||
12888 | 12895 |
| |
12889 | 12896 |
| |
12890 | 12897 |
| |
12891 |
| - | |
| 12898 | + | |
12892 | 12899 |
| |
12893 | 12900 |
| |
12894 | 12901 |
| |
|
0 commit comments
Comments
(0)