- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit5509055
Amit Kapila
Add sequence synchronization for logical replication.
This patch introduces sequence synchronization. Sequences that are syncedwill have 2 states: - INIT (needs [re]synchronizing) - READY (is already synchronized)A new sequencesync worker is launched as needed to synchronize sequences.A single sequencesync worker is responsible for synchronizing allsequences. It begins by retrieving the list of sequences that are flaggedfor synchronization, i.e., those in the INIT state. These sequences arethen processed in batches, allowing multiple entries to be synchronizedwithin a single transaction. The worker fetches the current sequencevalues and page LSNs from the remote publisher, updates the correspondingsequences on the local subscriber, and finally marks each sequence asREADY upon successful synchronization.Sequence synchronization occurs in 3 places:1) CREATE SUBSCRIPTION - The command syntax remains unchanged. - The subscriber retrieves sequences associated with publications. - Published sequences are added to pg_subscription_rel with INIT state. - Initiate the sequencesync worker to synchronize all sequences.2) ALTER SUBSCRIPTION ... REFRESH PUBLICATION - The command syntax remains unchanged. - Dropped published sequences are removed from pg_subscription_rel. - Newly published sequences are added to pg_subscription_rel with INIT state. - Initiate the sequencesync worker to synchronize only newly added sequences.3) ALTER SUBSCRIPTION ... REFRESH SEQUENCES - A new command introduced for PG19 byf0b3573. - All sequences in pg_subscription_rel are reset to INIT state. - Initiate the sequencesync worker to synchronize all sequences. - Unlike "ALTER SUBSCRIPTION ... REFRESH PUBLICATION" command, addition and removal of missing sequences will not be done in this case.Author: Vignesh C <vignesh21@gmail.com>Reviewed-by: shveta malik <shveta.malik@gmail.com>Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>Reviewed-by: Peter Smith <smithpb2250@gmail.com>Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Reviewed-by: Chao Li <li.evan.chao@gmail.com>Discussion:https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com1 parent1fd981f commit5509055
File tree
19 files changed
+1229
-126
lines changed- src
- backend
- catalog
- commands
- postmaster
- replication/logical
- utils/misc
- include
- catalog
- commands
- replication
- test/subscription/t
- tools/pgindent
19 files changed
+1229
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
| |||
954 | 953 | | |
955 | 954 | | |
956 | 955 | | |
957 | | - | |
958 | | - | |
| 956 | + | |
| 957 | + | |
959 | 958 | | |
960 | 959 | | |
961 | 960 | | |
| |||
1056 | 1055 | | |
1057 | 1056 | | |
1058 | 1057 | | |
1059 | | - | |
| 1058 | + | |
1060 | 1059 | | |
1061 | 1060 | | |
1062 | 1061 | | |
1063 | 1062 | | |
1064 | 1063 | | |
1065 | 1064 | | |
1066 | 1065 | | |
1067 | | - | |
| 1066 | + | |
1068 | 1067 | | |
1069 | 1068 | | |
1070 | 1069 | | |
1071 | 1070 | | |
1072 | 1071 | | |
1073 | 1072 | | |
1074 | | - | |
| 1073 | + | |
1075 | 1074 | | |
1076 | 1075 | | |
1077 | 1076 | | |
| |||
1080 | 1079 | | |
1081 | 1080 | | |
1082 | 1081 | | |
1083 | | - | |
| 1082 | + | |
1084 | 1083 | | |
1085 | 1084 | | |
1086 | 1085 | | |
| |||
1797 | 1796 | | |
1798 | 1797 | | |
1799 | 1798 | | |
1800 | | - | |
1801 | | - | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
1802 | 1802 | | |
1803 | 1803 | | |
1804 | 1804 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
253 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
254 | 256 | | |
255 | 257 | | |
256 | 258 | | |
| |||
334 | 336 | | |
335 | 337 | | |
336 | 338 | | |
| 339 | + | |
337 | 340 | | |
338 | 341 | | |
339 | 342 | | |
| |||
422 | 425 | | |
423 | 426 | | |
424 | 427 | | |
425 | | - | |
| 428 | + | |
| 429 | + | |
426 | 430 | | |
427 | 431 | | |
428 | 432 | | |
| |||
478 | 482 | | |
479 | 483 | | |
480 | 484 | | |
| 485 | + | |
481 | 486 | | |
482 | 487 | | |
483 | 488 | | |
| |||
511 | 516 | | |
512 | 517 | | |
513 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
514 | 527 | | |
515 | | - | |
| 528 | + | |
516 | 529 | | |
517 | 530 | | |
518 | 531 | | |
| |||
848 | 861 | | |
849 | 862 | | |
850 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
851 | 891 | | |
852 | 892 | | |
853 | 893 | | |
| |||
896 | 936 | | |
897 | 937 | | |
898 | 938 | | |
899 | | - | |
| 939 | + | |
900 | 940 | | |
901 | 941 | | |
902 | 942 | | |
| |||
1610 | 1650 | | |
1611 | 1651 | | |
1612 | 1652 | | |
1613 | | - | |
| 1653 | + | |
1614 | 1654 | | |
1615 | 1655 | | |
1616 | 1656 | | |
| |||
1650 | 1690 | | |
1651 | 1691 | | |
1652 | 1692 | | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
1653 | 1696 | | |
1654 | 1697 | | |
1655 | 1698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
0 commit comments
Comments
(0)