- Notifications
You must be signed in to change notification settings - Fork5
Commitabfd192
committed
Allow a streaming replication standby to follow a timeline switch.
Before this patch, streaming replication would refuse to start replicatingif the timeline in the primary doesn't exactly match the standby. Thesituation where it doesn't match is when you have a master, and twostandbys, and you promote one of the standbys to become new master.Promoting bumps up the timeline ID, and after that bump, the other standbywould refuse to continue.There's significantly more timeline related logic in streaming replicationnow. First of all, when a standby connects to primary, it will ask theprimary for any timeline history files that are missing from the standby.The missing files are sent using a new replication command TIMELINE_HISTORY,and stored in standby's pg_xlog directory. Using the timeline history files,the standby can follow the latest timeline present in the primary(recovery_target_timeline='latest'), just as it can follow new timelinesappearing in an archive directory.START_REPLICATION now takes a TIMELINE parameter, to specify exactly whichtimeline to stream WAL from. This allows the standby to request the primaryto send over WAL that precedes the promotion. The replication protocol ischanged slightly (in a backwards-compatible way although there's little hopeof streaming replication working across major versions anyway), to allowreplication to stop when the end of timeline reached, putting the walsenderback into accepting a replication command.Many thanks to Amit Kapila for testing and reviewing various versions ofthis patch.1 parent5276687 commitabfd192
File tree
23 files changed
+1396
-370
lines changed- doc/src/sgml
- src
- backend
- access/transam
- postmaster
- replication
- libpqwalreceiver
- include
- access
- nodes
- replication
- interfaces/libpq
23 files changed
+1396
-370
lines changedLines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
912 | 912 |
| |
913 | 913 |
| |
914 | 914 |
| |
915 |
| - | |
916 |
| - | |
917 |
| - | |
918 |
| - | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
919 | 918 |
| |
920 | 919 |
| |
921 | 920 |
| |
|
Lines changed: 67 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1018 | 1018 |
| |
1019 | 1019 |
| |
1020 | 1020 |
| |
1021 |
| - | |
| 1021 | + | |
1022 | 1022 |
| |
1023 | 1023 |
| |
1024 | 1024 |
| |
1025 | 1025 |
| |
1026 | 1026 |
| |
1027 |
| - | |
1028 |
| - | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1029 | 1036 |
| |
1030 | 1037 |
| |
1031 | 1038 |
| |
| |||
1350 | 1357 |
| |
1351 | 1358 |
| |
1352 | 1359 |
| |
1353 |
| - | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1354 | 1399 |
| |
1355 | 1400 |
| |
1356 | 1401 |
| |
1357 |
| - | |
| 1402 | + | |
| 1403 | + | |
1358 | 1404 |
| |
1359 | 1405 |
| |
1360 | 1406 |
| |
1361 |
| - | |
1362 |
| - | |
1363 |
| - | |
1364 |
| - | |
1365 |
| - | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
1366 | 1423 |
| |
1367 | 1424 |
| |
1368 | 1425 |
| |
|
Lines changed: 83 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
410 | 410 |
| |
411 | 411 |
| |
412 | 412 |
| |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
413 | 496 |
| |
414 | 497 |
| |
415 | 498 |
| |
|
Lines changed: 30 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
| 156 | + | |
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
| |||
6366 | 6367 |
| |
6367 | 6368 |
| |
6368 | 6369 |
| |
| 6370 | + | |
| 6371 | + | |
| 6372 | + | |
| 6373 | + | |
| 6374 | + | |
| 6375 | + | |
6369 | 6376 |
| |
6370 | 6377 |
| |
6371 | 6378 |
| |
| |||
7626 | 7633 |
| |
7627 | 7634 |
| |
7628 | 7635 |
| |
7629 |
| - | |
| 7636 | + | |
7630 | 7637 |
| |
7631 | 7638 |
| |
7632 | 7639 |
| |
| |||
9087 | 9094 |
| |
9088 | 9095 |
| |
9089 | 9096 |
| |
9090 |
| - | |
9091 |
| - | |
9092 |
| - | |
9093 | 9097 |
| |
9094 | 9098 |
| |
9095 | 9099 |
| |
9096 |
| - | |
| 9100 | + | |
9097 | 9101 |
| |
9098 | 9102 |
| |
9099 | 9103 |
| |
9100 | 9104 |
| |
9101 | 9105 |
| |
9102 | 9106 |
| |
9103 | 9107 |
| |
9104 |
| - | |
9105 |
| - | |
9106 | 9108 |
| |
9107 | 9109 |
| |
9108 | 9110 |
| |
| |||
9111 | 9113 |
| |
9112 | 9114 |
| |
9113 | 9115 |
| |
9114 |
| - | |
9115 |
| - | |
9116 |
| - | |
9117 | 9116 |
| |
9118 | 9117 |
| |
9119 |
| - | |
| 9118 | + | |
9120 | 9119 |
| |
9121 | 9120 |
| |
9122 | 9121 |
| |
9123 | 9122 |
| |
9124 |
| - | |
9125 |
| - | |
| 9123 | + | |
| 9124 | + | |
9126 | 9125 |
| |
9127 | 9126 |
| |
9128 | 9127 |
| |
| |||
9611 | 9610 |
| |
9612 | 9611 |
| |
9613 | 9612 |
| |
| 9613 | + | |
| 9614 | + | |
9614 | 9615 |
| |
| 9616 | + | |
9615 | 9617 |
| |
9616 | 9618 |
| |
9617 | 9619 |
| |
| |||
9626 | 9628 |
| |
9627 | 9629 |
| |
9628 | 9630 |
| |
9629 |
| - | |
9630 |
| - | |
| 9631 | + | |
| 9632 | + | |
| 9633 | + | |
| 9634 | + | |
| 9635 | + | |
| 9636 | + | |
| 9637 | + | |
| 9638 | + | |
9631 | 9639 |
| |
9632 | 9640 |
| |
9633 | 9641 |
| |
| |||
9653 | 9661 |
| |
9654 | 9662 |
| |
9655 | 9663 |
| |
9656 |
| - | |
9657 |
| - | |
| 9664 | + | |
| 9665 | + | |
9658 | 9666 |
| |
9659 |
| - | |
| 9667 | + | |
9660 | 9668 |
| |
9661 | 9669 |
| |
9662 | 9670 |
| |
| |||
9749 | 9757 |
| |
9750 | 9758 |
| |
9751 | 9759 |
| |
9752 |
| - | |
| 9760 | + | |
9753 | 9761 |
| |
9754 | 9762 |
| |
9755 | 9763 |
| |
| |||
9772 | 9780 |
| |
9773 | 9781 |
| |
9774 | 9782 |
| |
9775 |
| - | |
9776 |
| - | |
| 9783 | + | |
| 9784 | + | |
9777 | 9785 |
| |
9778 | 9786 |
| |
9779 | 9787 |
| |
| |||
9888 | 9896 |
| |
9889 | 9897 |
| |
9890 | 9898 |
| |
9891 |
| - | |
9892 |
| - | |
| 9899 | + | |
9893 | 9900 |
| |
9894 | 9901 |
| |
9895 | 9902 |
| |
| |||
9904 | 9911 |
| |
9905 | 9912 |
| |
9906 | 9913 |
| |
9907 |
| - | |
9908 | 9914 |
| |
9909 | 9915 |
| |
9910 | 9916 |
| |
| |||
9917 | 9923 |
| |
9918 | 9924 |
| |
9919 | 9925 |
| |
9920 |
| - | |
9921 | 9926 |
| |
9922 | 9927 |
| |
9923 | 9928 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
226 | 226 |
| |
227 | 227 |
| |
228 | 228 |
| |
229 |
| - | |
| 229 | + | |
230 | 230 |
| |
231 | 231 |
| |
232 | 232 |
| |
| |||
248 | 248 |
| |
249 | 249 |
| |
250 | 250 |
| |
251 |
| - | |
| 251 | + | |
252 | 252 |
| |
253 | 253 |
| |
254 | 254 |
| |
|
0 commit comments
Comments
(0)