- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit247ee94

Amit Kapila
Fix data loss in logical replication.
This commit is a backpatch of commit4909b38 for 13.Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ...or ALTER TYPE ... that don't take a strong lock on table happensconcurrently to DMLs on the tables involved in the DDL. This happensbecause logical decoding doesn't distribute invalidations to concurrenttransactions and those transactions use stale cache data to decode thechanges. The problem becomes bigger because we keep using the stale cacheeven after those in-progress transactions are finished and skip thechanges required to be sent to the client.This commit fixes the issue by distributing invalidation messages fromcatalog-modifying transactions to all concurrent in-progress transactions.This allows the necessary rebuild of the catalog cache when decoding newchanges after concurrent DDL.The fix for 13 is different from what we did in branches 14 and above,such that for 13, the concurrent DDL changes (from DDL types mentionedearlier) will be visible for any newly started transactions. To make themvisible in concurrent transactions, we need to introduce a new change typeREORDER_BUFFER_CHANGE_INVALIDATION, already present in branches 14 andgreater. We decided not to take the risk of a bigger change and fix theissue partially in 13.Reported-by: hubert depesz lubaczewski <depesz@depesz.com>Reported-by: Tomas Vondra <tomas.vondra@enterprisedb.com>Author: Shlok Kyal <shlok.kyal.oss@gmail.com>Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Tested-by: Benoit Lobréau <benoit.lobreau@dalibo.com>Discussion:https://postgr.es/m/de52b282-1166-1180-45a2-8d8917ca74c6@enterprisedb.comDiscussion:https://postgr.es/m/CAD21AoAenVqiMjpN-PvGHL1N9DWnHSq673bfgr6phmBUzx=kLQ@mail.gmail.comDiscussion:https://postgr.es/m/CAD21AoAhU3kp8shYqP=ExiFDZ9sZxpFb5WzLa0p+vEe5j+7CWQ@mail.gmail.com1 parentc5ba351 commit247ee94
File tree
6 files changed
+164
-21
lines changed- contrib/test_decoding
- expected
- specs
- src
- backend/replication/logical
- include/replication
6 files changed
+164
-21
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + |
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + |
Lines changed: 56 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2264 | 2264 |
| |
2265 | 2265 |
| |
2266 | 2266 |
| |
| 2267 | + | |
2267 | 2268 |
| |
2268 | 2269 |
| |
2269 | 2270 |
| |
2270 |
| - | |
2271 |
| - | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
2272 | 2282 |
| |
2273 | 2283 |
| |
2274 | 2284 |
| |
2275 |
| - | |
2276 |
| - | |
2277 |
| - | |
2278 |
| - | |
2279 |
| - | |
2280 |
| - | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
2281 | 2306 |
| |
2282 | 2307 |
| |
2283 | 2308 |
| |
| |||
3895 | 3920 |
| |
3896 | 3921 |
| |
3897 | 3922 |
| |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + |
Lines changed: 51 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
295 |
| - | |
| 295 | + | |
296 | 296 |
| |
297 | 297 |
| |
298 | 298 |
| |
| |||
861 | 861 |
| |
862 | 862 |
| |
863 | 863 |
| |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
868 |
| - | |
869 |
| - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
870 | 870 |
| |
871 | 871 |
| |
872 |
| - | |
| 872 | + | |
873 | 873 |
| |
874 | 874 |
| |
875 | 875 |
| |
876 | 876 |
| |
877 | 877 |
| |
878 | 878 |
| |
879 | 879 |
| |
880 |
| - | |
| 880 | + | |
| 881 | + | |
881 | 882 |
| |
882 | 883 |
| |
883 | 884 |
| |
| |||
890 | 891 |
| |
891 | 892 |
| |
892 | 893 |
| |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
893 | 902 |
| |
894 | 903 |
| |
895 | 904 |
| |
| |||
898 | 907 |
| |
899 | 908 |
| |
900 | 909 |
| |
901 |
| - | |
| 910 | + | |
902 | 911 |
| |
903 | 912 |
| |
904 | 913 |
| |
| |||
908 | 917 |
| |
909 | 918 |
| |
910 | 919 |
| |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
911 | 947 |
| |
912 | 948 |
| |
913 | 949 |
| |
| |||
1186 | 1222 |
| |
1187 | 1223 |
| |
1188 | 1224 |
| |
1189 |
| - | |
1190 |
| - | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1191 | 1230 |
| |
1192 | 1231 |
| |
1193 | 1232 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
463 | 463 |
| |
464 | 464 |
| |
465 | 465 |
| |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
466 | 470 |
| |
467 | 471 |
| |
468 | 472 |
|
0 commit comments
Comments
(0)