forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitddd5f4f

Amit Kapila
Add a slot synchronization function.
This commit introduces a new SQL function pg_sync_replication_slots()which is used to synchronize the logical replication slots from theprimary server to the physical standby so that logical replication can beresumed after a failover or planned switchover.A new 'synced' flag is introduced in pg_replication_slots view, indicatingwhether the slot has been synchronized from the primary server. On astandby, synced slots cannot be dropped or consumed, and any attempt toperform logical decoding on them will result in an error.The logical replication slots on the primary can be synchronized to thehot standby by using the 'failover' parameter ofpg-create-logical-replication-slot(), or by using the 'failover' option ofCREATE SUBSCRIPTION during slot creation, and then callingpg_sync_replication_slots() on standby. For the synchronization to work,it is mandatory to have a physical replication slot between the primaryand the standby aka 'primary_slot_name' should be configured on thestandby, and 'hot_standby_feedback' must be enabled on the standby. It isalso necessary to specify a valid 'dbname' in the 'primary_conninfo'.If a logical slot is invalidated on the primary, then that slot on thestandby is also invalidated.If a logical slot on the primary is valid but is invalidated on thestandby, then that slot is dropped but will be recreated on the standby inthe next pg_sync_replication_slots() call provided the slot still existson the primary server. It is okay to recreate such slots as long as theseare not consumable on standby (which is the case currently). Thissituation may occur due to the following reasons:- The 'max_slot_wal_keep_size' on the standby is insufficient to retainWAL records from the restart_lsn of the slot.- 'primary_slot_name' is temporarily reset to null and the physical slotis removed.The slot synchronization status on the standby can be monitored using the'synced' column of pg_replication_slots view.A functionality to automatically synchronize slots by a background workerand allow logical walsenders to wait for the physical will be done insubsequent commits.Author: Hou Zhijie, Shveta Malik, Ajin Cherian based on an earlier version by Peter EisentrautReviewed-by: Masahiko Sawada, Bertrand Drouvot, Peter Smith, Dilip Kumar, Nisha Moond, Kuroda Hayato, Amit KapilaDiscussion:https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com1 parent06bd311 commitddd5f4f
File tree
26 files changed
+1522
-37
lines changed- contrib/test_decoding
- expected
- sql
- doc/src/sgml
- src
- backend
- catalog
- replication
- logical
- storage/ipc
- include
- catalog
- replication
- test
- recovery/t
- regress/expected
- tools/pgindent
26 files changed
+1522
-37
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 |
| |
68 | 71 |
| |
69 | 72 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
425 | 425 |
| |
426 | 426 |
| |
427 | 427 |
| |
| 428 | + | |
| 429 | + | |
428 | 430 |
| |
429 | 431 |
| |
430 | 432 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
181 | 181 |
| |
182 | 182 |
| |
183 | 183 |
| |
| 184 | + | |
184 | 185 |
| |
185 | 186 |
| |
186 | 187 |
| |
|
Lines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4612 | 4612 |
| |
4613 | 4613 |
| |
4614 | 4614 |
| |
4615 |
| - | |
4616 |
| - | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
4617 | 4622 |
| |
4618 | 4623 |
| |
4619 | 4624 |
| |
|
Lines changed: 34 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28075 | 28075 |
| |
28076 | 28076 |
| |
28077 | 28077 |
| |
28078 |
| - | |
| 28078 | + | |
28079 | 28079 |
| |
28080 | 28080 |
| |
28081 | 28081 |
| |
| |||
28444 | 28444 |
| |
28445 | 28445 |
| |
28446 | 28446 |
| |
| 28447 | + | |
| 28448 | + | |
| 28449 | + | |
| 28450 | + | |
| 28451 | + | |
| 28452 | + | |
| 28453 | + | |
| 28454 | + | |
| 28455 | + | |
| 28456 | + | |
| 28457 | + | |
| 28458 | + | |
| 28459 | + | |
| 28460 | + | |
| 28461 | + | |
| 28462 | + | |
| 28463 | + | |
| 28464 | + | |
| 28465 | + | |
| 28466 | + | |
| 28467 | + | |
| 28468 | + | |
| 28469 | + | |
| 28470 | + | |
| 28471 | + | |
| 28472 | + | |
| 28473 | + | |
| 28474 | + | |
| 28475 | + | |
| 28476 | + | |
| 28477 | + | |
| 28478 | + | |
| 28479 | + | |
28447 | 28480 |
| |
28448 | 28481 |
| |
28449 | 28482 |
| |
|
Lines changed: 56 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
358 | 358 |
| |
359 | 359 |
| |
360 | 360 |
| |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
361 | 417 |
| |
362 | 418 |
| |
363 | 419 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2062 | 2062 |
| |
2063 | 2063 |
| |
2064 | 2064 |
| |
2065 |
| - | |
| 2065 | + | |
| 2066 | + | |
2066 | 2067 |
| |
2067 | 2068 |
| |
2068 | 2069 |
| |
| |||
2162 | 2163 |
| |
2163 | 2164 |
| |
2164 | 2165 |
| |
2165 |
| - | |
| 2166 | + | |
| 2167 | + | |
2166 | 2168 |
| |
2167 | 2169 |
| |
2168 | 2170 |
| |
|
Lines changed: 18 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2561 | 2561 |
| |
2562 | 2562 |
| |
2563 | 2563 |
| |
2564 |
| - | |
2565 |
| - | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
2566 | 2567 |
| |
2567 | 2568 |
| |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
2568 | 2584 |
| |
2569 | 2585 |
| |
2570 | 2586 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1024 | 1024 |
| |
1025 | 1025 |
| |
1026 | 1026 |
| |
1027 |
| - | |
| 1027 | + | |
| 1028 | + | |
1028 | 1029 |
| |
1029 | 1030 |
| |
1030 | 1031 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
524 | 524 |
| |
525 | 525 |
| |
526 | 526 |
| |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
527 | 539 |
| |
528 | 540 |
| |
529 | 541 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| 14 | + | |
14 | 15 |
| |
15 | 16 |
| |
16 | 17 |
| |
|
0 commit comments
Comments
(0)