- Notifications
You must be signed in to change notification settings - Fork5
Commitc4c2274
committed
Fix bugs in cascading replication with recovery_target_timeline='latest'
The cascading replication code assumed that the current RecoveryTargetTLInever changes, but that's not true with recovery_target_timeline='latest'.The obvious upshot of that is that RecoveryTargetTLI in shared memory needsto be protected by a lock. A less obvious consequence is that when acascading standby is connected, and the standby switches to a new targettimeline after scanning the archive, it will continue to stream WAL to thecascading standby, but from a wrong file, ie. the file of the previoustimeline. For example, if the standby is currently streaming from the middleof file 000000010000000000000005, and the timeline changes, the standbywill continue to stream from that file. However, the WAL on the newtimeline is in file 000000020000000000000005, so the standby sends garbagefrom 000000010000000000000005 to the cascading standby, instead of thecorrect WAL from file 000000020000000000000005.This also fixes a related bug where a partial WAL segment is restored fromthe archive and streamed to a cascading standby. The code assumed that whena WAL segment is copied from the archive, it can immediately be fullystreamed to a cascading standby. However, if the segment is only partiallyfilled, ie. has the right size, but only N first bytes contain valid WAL,that's not safe. That can happen if a partial WAL segment is manually copiedto the archive, or if a partial WAL segment is archived because a server isstarted up on a new timeline within that segment. The cascading standby willget confused if the WAL it received is not valid, and will get stuck untilit's restarted. This patch fixes that problem by not allowing WAL restoredfrom the archive to be streamed to a cascading standby until it's beenreplayed, and thus validated.1 parentcdf91ed commitc4c2274
File tree
3 files changed
+59
-35
lines changed- src
- backend
- access/transam
- replication
- include/access
3 files changed
+59
-35
lines changedLines changed: 31 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
411 | 410 |
| |
412 | 411 |
| |
413 | 412 |
| |
| |||
456 | 455 |
| |
457 | 456 |
| |
458 | 457 |
| |
| 458 | + | |
| 459 | + | |
459 | 460 |
| |
460 | 461 |
| |
461 | 462 |
| |
462 | 463 |
| |
463 | 464 |
| |
464 | 465 |
| |
465 |
| - | |
466 |
| - | |
467 | 466 |
| |
468 | 467 |
| |
469 | 468 |
| |
| |||
2817 | 2816 |
| |
2818 | 2817 |
| |
2819 | 2818 |
| |
2820 |
| - | |
2821 |
| - | |
2822 |
| - | |
2823 |
| - | |
2824 |
| - | |
2825 |
| - | |
2826 |
| - | |
2827 |
| - | |
2828 |
| - | |
2829 |
| - | |
2830 |
| - | |
2831 |
| - | |
2832 | 2819 |
| |
2833 | 2820 |
| |
2834 | 2821 |
| |
| |||
4470 | 4457 |
| |
4471 | 4458 |
| |
4472 | 4459 |
| |
| 4460 | + | |
| 4461 | + | |
| 4462 | + | |
4473 | 4463 |
| |
4474 | 4464 |
| |
4475 | 4465 |
| |
4476 | 4466 |
| |
4477 | 4467 |
| |
4478 |
| - | |
| 4468 | + | |
| 4469 | + | |
| 4470 | + | |
4479 | 4471 |
| |
4480 | 4472 |
| |
4481 | 4473 |
| |
| |||
7513 | 7505 |
| |
7514 | 7506 |
| |
7515 | 7507 |
| |
7516 |
| - | |
| 7508 | + | |
7517 | 7509 |
| |
7518 | 7510 |
| |
7519 | 7511 |
| |
7520 | 7512 |
| |
7521 |
| - | |
7522 |
| - | |
| 7513 | + | |
| 7514 | + | |
| 7515 | + | |
| 7516 | + | |
| 7517 | + | |
| 7518 | + | |
| 7519 | + | |
| 7520 | + | |
| 7521 | + | |
7523 | 7522 |
| |
7524 | 7523 |
| |
7525 | 7524 |
| |
| |||
8309 | 8308 |
| |
8310 | 8309 |
| |
8311 | 8310 |
| |
8312 |
| - | |
| 8311 | + | |
8313 | 8312 |
| |
8314 | 8313 |
| |
8315 | 8314 |
| |
| |||
9818 | 9817 |
| |
9819 | 9818 |
| |
9820 | 9819 |
| |
9821 |
| - | |
9822 |
| - | |
9823 |
| - | |
| 9820 | + | |
| 9821 | + | |
9824 | 9822 |
| |
9825 | 9823 |
| |
9826 | 9824 |
| |
9827 | 9825 |
| |
9828 |
| - | |
| 9826 | + | |
9829 | 9827 |
| |
9830 | 9828 |
| |
9831 | 9829 |
| |
9832 | 9830 |
| |
9833 | 9831 |
| |
9834 | 9832 |
| |
9835 | 9833 |
| |
9836 |
| - | |
9837 |
| - | |
| 9834 | + | |
| 9835 | + | |
9838 | 9836 |
| |
9839 | 9837 |
| |
9840 | 9838 |
| |
| |||
9843 | 9841 |
| |
9844 | 9842 |
| |
9845 | 9843 |
| |
| 9844 | + | |
| 9845 | + | |
| 9846 | + | |
9846 | 9847 |
| |
9847 | 9848 |
| |
9848 |
| - | |
| 9849 | + | |
9849 | 9850 |
| |
9850 | 9851 |
| |
9851 | 9852 |
| |
9852 |
| - | |
9853 | 9853 |
| |
9854 | 9854 |
| |
9855 |
| - | |
| 9855 | + | |
9856 | 9856 |
| |
9857 | 9857 |
| |
9858 |
| - | |
| 9858 | + | |
9859 | 9859 |
| |
9860 |
| - | |
| 9860 | + | |
9861 | 9861 |
| |
9862 | 9862 |
| |
9863 | 9863 |
| |
|
Lines changed: 26 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
303 | 303 |
| |
304 | 304 |
| |
305 | 305 |
| |
306 |
| - | |
| 306 | + | |
307 | 307 |
| |
308 | 308 |
| |
309 | 309 |
| |
| |||
1137 | 1137 |
| |
1138 | 1138 |
| |
1139 | 1139 |
| |
1140 |
| - | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1141 | 1165 |
| |
1142 | 1166 |
| |
1143 | 1167 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
288 |
| - | |
289 |
| - | |
| 288 | + | |
| 289 | + | |
290 | 290 |
| |
291 | 291 |
| |
292 | 292 |
| |
|
0 commit comments
Comments
(0)