- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit45c357e
committed
Fix re-distributing previously distributed invalidation messages during logical decoding.
Commit4909b38 introduced logic to distribute invalidation messagesfrom catalog-modifying transactions to all concurrent in-progresstransactions. However, since each transaction distributes not only itsoriginal invalidation messages but also previously distributedmessages to other transactions, this leads to an exponential increasein allocation request size for invalidation messages, ultimatelycausing memory allocation failure.This commit fixes this issue by tracking distributed invalidationmessages separately per decoded transaction and not redistributingthese messages to other in-progress transactions. The maximum size ofdistributed invalidation messages that one transaction can store islimited to MAX_DISTR_INVAL_MSG_PER_TXN (8MB). Once the size of thedistributed invalidation messages exceeds this threshold, weinvalidate all caches in locations where distributed invalidationmessages need to be executed.Back-patch to all supported versions where we introduced the fix bycommit4909b38.Note that this commit adds two new fields to ReorderBufferTXN to storethe distributed transactions. This change breaks ABI compatibility inback branches, affecting third-party extensions that depend on thesize of the ReorderBufferTXN struct, though this scenario seemsunlikely.Additionally, it adds a new flag to the txn_flags field ofReorderBufferTXN to indicate distributed invalidation messageoverflow. This should not affect existing implementations, as it isunlikely that third-party extensions use unused bits in the txn_flagsfield.Bug: #18938 #18942Author: vignesh C <vignesh21@gmail.com>Reported-by: Duncan Sands <duncan.sands@deepbluecap.com>Reported-by: John Hutchins <john.hutchins@wicourts.gov>Reported-by: Laurence Parry <greenreaper@hotmail.com>Reported-by: Max Madden <maxmmadden@gmail.com>Reported-by: Braulio Fdo Gonzalez <brauliofg@gmail.com>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Discussion:https://postgr.es/m/680bdaf6-f7d1-4536-b580-05c2760c67c6@deepbluecap.comDiscussion:https://postgr.es/m/18942-0ab1e5ae156613ad@postgresql.orgDiscussion:https://postgr.es/m/18938-57c9a1c463b68ce0@postgresql.orgDiscussion:https://postgr.es/m/CAD1FGCT2sYrP_70RTuo56QTizyc+J3wJdtn2gtO3VttQFpdMZg@mail.gmail.comDiscussion:https://postgr.es/m/CANO2=B=2BT1hSYCE=nuuTnVTnjidMg0+-FfnRnqM6kd23qoygg@mail.gmail.comBackpatch-through: 131 parent32ab0fd commit45c357e
File tree
5 files changed
+231
-45
lines changed- contrib/test_decoding
- expected
- specs
- src
- backend/replication/logical
- include/replication
5 files changed
+231
-45
lines changedLines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
| |||
469 | 481 | | |
470 | 482 | | |
471 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
472 | 490 | | |
473 | 491 | | |
474 | 492 | | |
| |||
2574 | 2592 | | |
2575 | 2593 | | |
2576 | 2594 | | |
2577 | | - | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
2578 | 2606 | | |
2579 | 2607 | | |
2580 | 2608 | | |
| |||
2620 | 2648 | | |
2621 | 2649 | | |
2622 | 2650 | | |
2623 | | - | |
2624 | | - | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2625 | 2662 | | |
2626 | 2663 | | |
2627 | 2664 | | |
| |||
2951 | 2988 | | |
2952 | 2989 | | |
2953 | 2990 | | |
2954 | | - | |
| 2991 | + | |
| 2992 | + | |
2955 | 2993 | | |
2956 | 2994 | | |
2957 | 2995 | | |
| |||
3038 | 3076 | | |
3039 | 3077 | | |
3040 | 3078 | | |
3041 | | - | |
3042 | | - | |
3043 | | - | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
3044 | 3083 | | |
3045 | 3084 | | |
3046 | 3085 | | |
| |||
3312 | 3351 | | |
3313 | 3352 | | |
3314 | 3353 | | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
3315 | 3405 | | |
3316 | 3406 | | |
3317 | 3407 | | |
| |||
3332 | 3422 | | |
3333 | 3423 | | |
3334 | 3424 | | |
3335 | | - | |
3336 | 3425 | | |
3337 | 3426 | | |
3338 | 3427 | | |
| |||
3347 | 3436 | | |
3348 | 3437 | | |
3349 | 3438 | | |
3350 | | - | |
3351 | | - | |
3352 | | - | |
3353 | | - | |
3354 | | - | |
3355 | | - | |
3356 | | - | |
3357 | | - | |
3358 | | - | |
3359 | | - | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
3360 | 3481 | | |
3361 | | - | |
3362 | | - | |
3363 | | - | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
3364 | 3493 | | |
3365 | | - | |
3366 | | - | |
3367 | | - | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
3368 | 3505 | | |
3369 | 3506 | | |
3370 | | - | |
3371 | | - | |
3372 | | - | |
3373 | | - | |
3374 | | - | |
3375 | | - | |
3376 | | - | |
3377 | | - | |
3378 | | - | |
| 3507 | + | |
| 3508 | + | |
3379 | 3509 | | |
3380 | 3510 | | |
3381 | 3511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
932 | 932 | | |
933 | 933 | | |
934 | 934 | | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
935 | 942 | | |
936 | 943 | | |
937 | 944 | | |
| |||
945 | 952 | | |
946 | 953 | | |
947 | 954 | | |
948 | | - | |
949 | | - | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
950 | 958 | | |
951 | 959 | | |
952 | 960 | | |
| |||
0 commit comments
Comments
(0)