postgresql/src/include/replication
Amit Kapila bf07ab492c Avoid unnecessary streaming of transactions during logical replication.
After restart, we don't perform streaming of an in-progress transaction if
it was previously decoded and confirmed by the client. To achieve that we
were comparing the END location of the WAL record being decoded with the
WAL location we have already decoded and confirmed by the client. While
decoding the commit record, to decide whether to process and send the
complete transaction, we compare its START location with the WAL location
we have already decoded and confirmed by the client. Now, if we need to
queue some change in the transaction while decoding the commit record
(e.g. snapshot), it is possible that we decide to stream the transaction
but later commit processing decides to skip it. In such a case, we would
needlessly send the changes and later when we decide to skip it, we will
send stream abort.

We also sometimes decide to stream the changes when we actually just need
to process them locally like a change for invalidations. This will lead us
to send empty streams. To avoid this, while queuing each change for
decoding, we remember whether the transaction has any change that actually
needs to be sent downstream and use that information later to decide
whether to stream the transaction or not.

Note, we can't avoid all cases where we have to send empty streams like
the case where the plugin later decides that the change is not
publishable. However, we will no longer need to send stream_abort when we
skip sending a particular transaction.

Author: Dilip Kumar
Reviewed-by: Hou Zhijie, Ashutosh Bapat, Shi yu, Amit Kapila
Discussion: https://postgr.es/m/CAFiTN-tHK=7LzfrPs8fbT2ksrOJGQbzywcgXst2bM9-rJJAAUg@mail.gmail.com
2022-12-08 06:05:09 +05:30
..
decode.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
logical.h Harmonize parameter names in storage and AM code. 2022-09-19 19:18:36 -07:00
logicallauncher.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
logicalproto.h Fix incorrect output from pgoutput when using column lists. 2022-12-02 10:52:58 +05:30
logicalrelation.h Fix data inconsistency between publisher and subscriber. 2022-06-16 08:45:07 +05:30
logicalworker.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
message.h Add missing 'extern' to function prototypes. 2022-05-12 12:39:33 -07:00
origin.h Harmonize parameter names in storage and AM code. 2022-09-19 19:18:36 -07:00
output_plugin.h Add central declarations for dlsym()ed symbols 2022-07-17 17:23:42 -07:00
pgoutput.h Allow users to skip logical replication of data having origin. 2022-07-21 08:47:38 +05:30
reorderbuffer.h Avoid unnecessary streaming of transactions during logical replication. 2022-12-08 06:05:09 +05:30
slot.h pgstat: Prevent stats reset from corrupting slotname by removing slotname 2022-10-08 09:43:29 -07:00
snapbuild.h Remove unused xid parameter. 2022-09-26 08:47:00 +05:30
syncrep.h Harmonize lexer adjacent function parameter names. 2022-09-21 13:21:36 -07:00
walreceiver.h Remove replacement code for getaddrinfo. 2022-08-14 09:53:28 +12:00
walsender.h Harmonize parameter names in storage and AM code. 2022-09-19 19:18:36 -07:00
walsender_private.h Harmonize more lexer function parameter names. 2022-09-22 13:27:16 -07:00
worker_internal.h Add a common function to generate the origin name. 2022-10-11 10:37:52 +05:30