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

Amit Kapila
Avoid unnecessary streaming of transactions during logical replication.
After restart, we don't perform streaming of an in-progress transaction ifit was previously decoded and confirmed by the client. To achieve that wewere comparing the END location of the WAL record being decoded with theWAL location we have already decoded and confirmed by the client. Whiledecoding the commit record, to decide whether to process and send thecomplete transaction, we compare its START location with the WAL locationwe have already decoded and confirmed by the client. Now, if we need toqueue some change in the transaction while decoding the commit record(e.g. snapshot), it is possible that we decide to stream the transactionbut later commit processing decides to skip it. In such a case, we wouldneedlessly send the changes and later when we decide to skip it, we willsend stream abort.We also sometimes decide to stream the changes when we actually just needto process them locally like a change for invalidations. This will lead usto send empty streams. To avoid this, while queuing each change fordecoding, we remember whether the transaction has any change that actuallyneeds to be sent downstream and use that information later to decidewhether to stream the transaction or not.Note, we can't avoid all cases where we have to send empty streams likethe case where the plugin later decides that the change is notpublishable. However, we will no longer need to send stream_abort when weskip sending a particular transaction.Author: Dilip KumarReviewed-by: Hou Zhijie, Ashutosh Bapat, Shi yu, Amit KapilaDiscussion:https://postgr.es/m/CAFiTN-tHK=7LzfrPs8fbT2ksrOJGQbzywcgXst2bM9-rJJAAUg@mail.gmail.com1 parent3f0e786 commitbf07ab4
File tree
2 files changed
+53
-21
lines changed- src
- backend/replication/logical
- include/replication
2 files changed
+53
-21
lines changedLines changed: 38 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
695 | 695 |
| |
696 | 696 |
| |
697 | 697 |
| |
698 |
| - | |
699 |
| - | |
700 |
| - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
701 | 701 |
| |
702 | 702 |
| |
703 | 703 |
| |
| |||
762 | 762 |
| |
763 | 763 |
| |
764 | 764 |
| |
765 |
| - | |
| 765 | + | |
| 766 | + | |
766 | 767 |
| |
767 | 768 |
| |
768 | 769 |
| |
| |||
793 | 794 |
| |
794 | 795 |
| |
795 | 796 |
| |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
796 | 820 |
| |
797 | 821 |
| |
798 | 822 |
| |
| |||
2942 | 2966 |
| |
2943 | 2967 |
| |
2944 | 2968 |
| |
2945 |
| - | |
2946 |
| - | |
2947 |
| - | |
| 2969 | + | |
| 2970 | + | |
2948 | 2971 |
| |
2949 | 2972 |
| |
2950 | 2973 |
| |
| |||
3460 | 3483 |
| |
3461 | 3484 |
| |
3462 | 3485 |
| |
3463 |
| - | |
| 3486 | + | |
3464 | 3487 |
| |
3465 | 3488 |
| |
3466 | 3489 |
| |
3467 | 3490 |
| |
3468 | 3491 |
| |
3469 | 3492 |
| |
3470 |
| - | |
| 3493 | + | |
| 3494 | + | |
3471 | 3495 |
| |
3472 | 3496 |
| |
3473 | 3497 |
| |
| |||
3483 | 3507 |
| |
3484 | 3508 |
| |
3485 | 3509 |
| |
3486 |
| - | |
| 3510 | + | |
3487 | 3511 |
| |
3488 | 3512 |
| |
3489 | 3513 |
| |
| |||
3502 | 3526 |
| |
3503 | 3527 |
| |
3504 | 3528 |
| |
3505 |
| - | |
| 3529 | + | |
| 3530 | + | |
3506 | 3531 |
| |
3507 | 3532 |
| |
3508 | 3533 |
| |
| |||
3547 | 3572 |
| |
3548 | 3573 |
| |
3549 | 3574 |
| |
3550 |
| - | |
| 3575 | + | |
3551 | 3576 |
| |
3552 | 3577 |
| |
3553 | 3578 |
| |
| |||
3919 | 3944 |
| |
3920 | 3945 |
| |
3921 | 3946 |
| |
3922 |
| - | |
| 3947 | + | |
3923 | 3948 |
| |
3924 | 3949 |
| |
3925 | 3950 |
| |
|
Lines changed: 15 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
168 | 168 |
| |
169 | 169 |
| |
170 | 170 |
| |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
179 | 180 |
| |
180 | 181 |
| |
181 | 182 |
| |
| |||
207 | 208 |
| |
208 | 209 |
| |
209 | 210 |
| |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
210 | 217 |
| |
211 | 218 |
| |
212 | 219 |
| |
|
0 commit comments
Comments
(0)