forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfef5b47
committed
Ensure that a standby is able to follow a primary on a newer timeline.
Commit709d003 refactored WAL-reading code, but accidentally causedWalSndSegmentOpen() to fail to follow a timeline switch while reading froma historic timeline. This issue caused a standby to fail to follow a primaryon a newer timeline when WAL archiving is enabled.If there is a timeline switch within the segment, WalSndSegmentOpen() shouldread from the WAL segment belonging to the new timeline. But previouslysince it failed to follow a timeline switch, it tried to read the WAL segmentwith old timeline. When WAL archiving is enabled, that WAL segment withold timeline doesn't exist because it's renamed to .partial. This leadsa primary to have tried to read non-existent WAL segment, and which causedreplication to faill with the error "ERROR: requested WAL segment ... has already been removed".This commit fixes WalSndSegmentOpen() so that it's able to follow a timelineswitch, to ensure that a standby is able to follow a primary on a newertimeline even when WAL archiving is enabled.This commit also adds the regression test to check whether a standby isable to follow a primary on a newer timeline when WAL archiving is enabled.Back-patch to v13 where the bug was introduced.Reported-by: Kyotaro HoriguchiAuthor: Kyotaro Horiguchi, tweaked by Fujii MasaoReviewed-by: Alvaro Herrera, Fujii MasaoDiscussion:https://postgr.es/m/20201209.174314.282492377848029776.horikyota.ntt@gmail.com1 parentaef8948 commitfef5b47
File tree
2 files changed
+40
-4
lines changed- src
- backend/replication
- test/recovery/t
2 files changed
+40
-4
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2491 | 2491 |
| |
2492 | 2492 |
| |
2493 | 2493 |
| |
2494 |
| - | |
| 2494 | + | |
2495 | 2495 |
| |
2496 | 2496 |
| |
2497 | 2497 |
| |
|
Lines changed: 39 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 |
| - | |
3 |
| - | |
4 | 2 |
| |
5 | 3 |
| |
6 | 4 |
| |
7 | 5 |
| |
8 | 6 |
| |
9 |
| - | |
| 7 | + | |
10 | 8 |
| |
11 | 9 |
| |
12 | 10 |
| |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 |
| |
14 | 15 |
| |
15 | 16 |
| |
| |||
66 | 67 |
| |
67 | 68 |
| |
68 | 69 |
| |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + |
0 commit comments
Comments
(0)