Re: Skipping logical replication transactions on subscriber side
Masahiko Sawada <sawada.mshk@gmail.com>
On Thu, Mar 17, 2022 at 5:52 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > On Thu, Mar 17, 2022 at 12:39 PM osumi.takamichi@fujitsu.com > <osumi.takamichi@fujitsu.com> wrote: > > > > On Thursday, March 17, 2022 3:04 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > > On Wed, Mar 16, 2022 at 1:53 PM Masahiko Sawada > > > <sawada.mshk@gmail.com> wrote: > > > > > > > > I've attached an updated version patch. > > > > > > > > > > The patch LGTM. I have made minor changes in comments and docs in the > > > attached patch. Kindly let me know what you think of the attached? > > Hi, thank you for the patch. Few minor comments. > > > > > > (1) comment of maybe_start_skipping_changes > > > > > > + /* > > + * Quick return if it's not requested to skip this transaction. This > > + * function is called for every remote transaction and we assume that > > + * skipping the transaction is not used often. > > + */ > > > > I feel this comment should explain more about our intention and > > what it confirms. In a case when user requests skip, > > but it doesn't match the condition, we don't start > > skipping changes, strictly speaking. > > > > From: > > Quick return if it's not requested to skip this transaction. > > > > To: > > Quick return if we can't ensure possible skiplsn is set > > and it equals to the finish LSN of this transaction. > > > > Hmm, the current comment seems more appropriate. What you are > suggesting is almost writing the code in sentence form. > > > > > (2) 029_on_error.pl > > > > + my $contents = slurp_file($node_subscriber->logfile, $offset); > > + $contents =~ > > + qr/processing remote data for replication origin \"pg_\d+\" during "INSERT" for replication target relation "public.tbl" in transaction \d+ finishe$ > > + or die "could not get error-LSN"; > > > > I think we shouldn't use a lot of new words. > > > > How about a change below ? > > > > From: > > could not get error-LSN > > To: > > failed to find expected error message that contains finish LSN for SKIP option > > > > > > (3) apply_handle_commit_internal > > > ... > > > > I feel if we move those two functions at the end > > of the apply_handle_commit and apply_handle_stream_commit, > > then we will have more aligned codes and improve readability. > > I think we cannot just move them to the end of apply_handle_commit() and apply_handle_stream_commit(). Because if we do that, we end up missing updating replication_session_origin_lsn/timestamp when clearing the subskiplsn if we're skipping a non-stream transaction. Basically, the apply worker differently handles 2pc transactions and non-2pc transactions; we always prepare even empty transactions whereas we don't commit empty non-2pc transactions. So I think we don’t have to handle both in the same way. > I think the intention is to avoid duplicate code as we have a common > function that gets called from both of those. Yes. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/
Commits
-
Test ALIGNOF_DOUBLE==4 compatibility under ALIGNOF_DOUBLE==8.
- c1da0acbb06e 15.0 landed
-
Reorder subskiplsn in pg_subscription to avoid alignment issues.
- 79b716cfb7a1 15.0 landed
-
Add ALTER SUBSCRIPTION ... SKIP.
- 208c5d65bbd6 15.0 landed
-
Optionally disable subscriptions on error.
- 705e20f8550c 15.0 cited
-
Update docs of logical replication for commit 8d74fc96db.
- 85c61ba8920b 15.0 landed
-
Respect permissions within logical replication.
- a2ab9c06ea15 15.0 cited
-
Fix regression test failure caused by commit 8d74fc96db.
- 41e66fee0516 15.0 landed
-
Add a view to show the stats of subscription workers.
- 8d74fc96db5f 15.0 landed
-
Add logical change details to logical replication worker errcontext.
- abc0910e2e0a 15.0 landed
-
Rename LOGICAL_REP_MSG_STREAM_END to LOGICAL_REP_MSG_STREAM_STOP.
- 4cd7a1896871 15.0 landed
-
Fix typo in protocol.sgml.
- e1915646658d 14.0 landed
- 0ac1aee0d7d8 15.0 landed
-
Remove unused argument in apply_handle_commit_internal().
- f4b939f1a372 14.0 landed
- 16bd4becee32 15.0 landed
-
Fix replication of in-progress transactions in tablesync worker.
- 0926e96c4934 14.0 cited
-
Reorder pg_sequence columns to avoid alignment issue
- f3b421da5f4a 10.0 cited