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

Amit Kapila
Fix catalog lookup with the wrong snapshot during logical decoding.
Previously, we relied on HEAP2_NEW_CID records and XACT_INVALIDATIONrecords to know if the transaction has modified the catalog, and thatinformation is not serialized to snapshot. Therefore, after the restart,if the logical decoding decodes only the commit record of the transactionthat has actually modified a catalog, we will miss adding its XID to thesnapshot. Thus, we will end up looking at catalogs with the wrongsnapshot.To fix this problem, this changes the snapshot builder so that itremembers the last-running-xacts list of the decoded RUNNING_XACTS recordafter restoring the previously serialized snapshot. Then, we mark thetransaction as containing catalog changes if it's in the list of initialrunning transactions and its commit record has XACT_XINFO_HAS_INVALS. Toavoid ABI breakage, we store the array of the initial running transactionsin the static variables InitialRunningXacts and NInitialRunningXacts,instead of storing those in SnapBuild or ReorderBuffer.This approach has a false positive; we could end up adding the transactionthat didn't change catalog to the snapshot since we cannot distinguishwhether the transaction has catalog changes only by checking the COMMITrecord. It doesn't have the information on which (sub) transaction hascatalog changes, and XACT_XINFO_HAS_INVALS doesn't necessarily indicatethat the transaction has catalog change. But that won't be a problem sincewe use snapshot built during decoding only to read system catalogs.On the master branch, we took a more future-proof approach by writingcatalog modifying transactions to the serialized snapshot which avoids theabove false positive. But we cannot backpatch it because of a change inthe SnapBuild.Reported-by: Mike OhAuthor: Masahiko SawadaReviewed-by: Amit Kapila, Shi yu, Takamichi Osumi, Kyotaro Horiguchi, Bertrand Drouvot, Ahsan HadiBackpatch-through: 10Discussion:https://postgr.es/m/81D0D8B0-E7C4-4999-B616-1E5004DBDCD2%40amazon.com1 parent71caf3c commit547b963
File tree
6 files changed
+227
-9
lines changed- contrib/test_decoding
- expected
- specs
- src
- backend/replication/logical
- include/replication
6 files changed
+227
-9
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
|
Lines changed: 44 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 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + |
Lines changed: 39 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 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + |
Lines changed: 14 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
582 | 582 |
| |
583 | 583 |
| |
584 | 584 |
| |
585 |
| - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
586 | 599 |
| |
587 | 600 |
| |
588 | 601 |
| |
|
Lines changed: 126 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
252 | 252 |
| |
253 | 253 |
| |
254 | 254 |
| |
255 |
| - | |
256 |
| - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
257 | 287 |
| |
258 | 288 |
| |
259 | 289 |
| |
| |||
890 | 920 |
| |
891 | 921 |
| |
892 | 922 |
| |
893 |
| - | |
894 |
| - | |
895 |
| - | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
896 | 931 |
| |
897 | 932 |
| |
898 |
| - | |
| 933 | + | |
899 | 934 |
| |
900 | 935 |
| |
901 | 936 |
| |
| |||
930 | 965 |
| |
931 | 966 |
| |
932 | 967 |
| |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
933 | 1011 |
| |
934 | 1012 |
| |
935 | 1013 |
| |
| |||
1137 | 1215 |
| |
1138 | 1216 |
| |
1139 | 1217 |
| |
1140 |
| - | |
| 1218 | + | |
1141 | 1219 |
| |
1142 | 1220 |
| |
1143 | 1221 |
| |
| |||
1288 | 1366 |
| |
1289 | 1367 |
| |
1290 | 1368 |
| |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1291 | 1383 |
| |
1292 | 1384 |
| |
1293 | 1385 |
| |
| |||
2030 | 2122 |
| |
2031 | 2123 |
| |
2032 | 2124 |
| |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + |
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 |
|
0 commit comments
Comments
(0)