Re: logical replication empty transactions
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: "osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com>
Cc: Ajin Cherian <itsajin@gmail.com>, Peter Smith <smithpb2250@gmail.com>, vignesh C <vignesh21@gmail.com>, Michael Paquier <michael@paquier.xyz>, Rahila Syed <rahila.syed@2ndquadrant.com>,
Euler Taveira <euler@timbira.com.br>, Dilip Kumar <dilipbalaut@gmail.com>, Jeff Janes <jeff.janes@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>,
Craig Ringer <craig@2ndquadrant.com>
Date: 2022-02-17T11:23:38Z
Lists: pgsql-hackers
On Wed, Feb 16, 2022 at 8:45 AM osumi.takamichi@fujitsu.com <osumi.takamichi@fujitsu.com> wrote: [ideas to skip empty prepare/commit_prepare ....] > > I feel if we don't want to change the protocol of commit_prepared, > we need to make the publisher solely judge whether the prepare was empty or not, > after the restart. > > One idea I thought at the beginning was to utilize and apply > the existing mechanism to spill ReorderBufferSerializeTXN object to local disk, > by postponing the prepare txn object cleanup and when the walsender exits > and commit prepared didn't come, spilling the transaction's data, > then restoring it after the restart in the DecodePrepare. > However, this idea wasn't crash-safe fundamentally. It means, > if the publisher crashes before spilling the empty prepare transaction, > we fail to detect the prepare was empty and come down to send the commit_prepared > in the situation where the subscriber didn't get the prepare data again. > So, I thought to utilize the spill mechanism didn't work for this purpose. > > Another idea would be, to create an empty file under the the pg_replslot/slotname > with a prefix different from "xid" in the DecodePrepare before the shutdown > if the prepare was empty, and bypass the cleanup of the serialized txns > and check the existence after the restart. But, this is pretty ad-hoc and I wasn't sure > if to address the corner case of the restart has the strong enough justification > to create this new file format. > I think for this idea to work you need to create such an empty file each time we skip empty prepare as the system might crash after prepare and we won't get time to create such a file. I don't think it is advisable to do I/O to save the network message. > Therefore, in my humble opinion, the idea of protocol change slightly wins, > since the impact of the protocol change would not be big. We introduced > the protocol version 3 in the devel version and the number of users should be little. > There is also the cost of the additional check (whether prepared xact exists) at the time of processing each commit prepared message. I think if we want to go in this direction then it is better to do it via a subscription parameter (say skip_empty_prepare_xact or something like that) so that we can pay the additional cost of such a check conditionally when such a parameter is set by the user. I feel for now we can document in comments why we can't skip empty prepared transactions and maybe as an idea(s) worth exploring to implement the same. OTOH, if multiple agree on such a solution we can even try to implement it and see if that works. -- With Regards, Amit Kapila.
Commits
-
Skip empty transactions for logical replication.
- d5a9d86d8ffc 15.0 landed
-
Add decoding of sequences to built-in replication
- 75b1521dae1f 15.0 cited
-
Allow specifying row filters for logical replication of tables.
- 52e4f0cd472d 15.0 cited