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

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 change adds the list of transaction IDs andsub-transaction IDs, that have modified catalogs and are running duringsnapshot serialization, to the serialized snapshot. After restart orotherwise, when we restore from such a serialized snapshot, thecorresponding list is restored in memory. Now, when decoding a COMMITrecord, we check both the list and the ReorderBuffer to see if thetransaction has modified catalogs.Since this adds additional information to the serialized snapshot, wecannot backpatch it. For back branches, we took another approach.We remember the last-running-xacts list of the decoded RUNNING_XACTSrecord after restoring the previously serialized snapshot. Then, we markthe transaction as containing catalog changes if it's in the list ofinitial running transactions and its commit record hasXACT_XINFO_HAS_INVALS. This doesn't require any file format changes butthe transaction will end up being added to the snapshot even if it hasonly relcache invalidations. But that won't be a problem since we usesnapshot built during decoding only to read system catalogs.This commit bumps SNAPBUILD_VERSION because of a change in 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 parent37a6e5d commit7f13ac8
File tree
8 files changed
+353
-93
lines changed- contrib/test_decoding
- expected
- specs
- src
- backend/replication/logical
- include/replication
8 files changed
+353
-93
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: 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: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
628 | 628 |
| |
629 | 629 |
| |
630 | 630 |
| |
631 |
| - | |
| 631 | + | |
| 632 | + | |
632 | 633 |
| |
633 | 634 |
| |
634 | 635 |
| |
|
Lines changed: 66 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
349 | 349 |
| |
350 | 350 |
| |
351 | 351 |
| |
| 352 | + | |
| 353 | + | |
352 | 354 |
| |
353 | 355 |
| |
354 | 356 |
| |
| |||
366 | 368 |
| |
367 | 369 |
| |
368 | 370 |
| |
| 371 | + | |
369 | 372 |
| |
370 | 373 |
| |
371 | 374 |
| |
| |||
1526 | 1529 |
| |
1527 | 1530 |
| |
1528 | 1531 |
| |
1529 |
| - | |
| 1532 | + | |
1530 | 1533 |
| |
1531 | 1534 |
| |
1532 | 1535 |
| |
1533 | 1536 |
| |
1534 |
| - | |
| 1537 | + | |
| 1538 | + | |
1535 | 1539 |
| |
1536 | 1540 |
| |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
1537 | 1548 |
| |
1538 | 1549 |
| |
1539 | 1550 |
| |
| |||
3275 | 3286 |
| |
3276 | 3287 |
| |
3277 | 3288 |
| |
| 3289 | + | |
3278 | 3290 |
| |
3279 | 3291 |
| |
3280 | 3292 |
| |
3281 |
| - | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
3282 | 3299 |
| |
3283 | 3300 |
| |
3284 | 3301 |
| |
3285 | 3302 |
| |
3286 | 3303 |
| |
3287 | 3304 |
| |
3288 | 3305 |
| |
3289 |
| - | |
3290 |
| - | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
3291 | 3352 |
| |
3292 | 3353 |
| |
3293 | 3354 |
| |
|
0 commit comments
Comments
(0)