RE: Skipping logical replication transactions on subscriber side
Takamichi Osumi (Fujitsu) <osumi.takamichi@fujitsu.com>
On Wednesday, March 2, 2022 12:01 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > I've attached an updated patch along with two patches for cfbot tests since the > main patch (0003) depends on the other two patches. Both > 0001 and 0002 patches are the same ones I attached on another thread[2]. Hi, few comments on v12-0003-Add-ALTER-SUBSCRIPTION-.-SKIP-to-skip-the-transa.patch. (1) doc/src/sgml/ref/alter_subscription.sgml + <term><literal>SKIP ( <replaceable class="parameter">skip_option</replaceable> = <replaceable class="parameter">value</r$ ... + ...After logical replication + successfully skips the transaction or commits non-empty transaction, + the LSN (stored in + <structname>pg_subscription</structname>.<structfield>subskiplsn</structfield>) + is cleared. See <xref linkend="logical-replication-conflicts"/> for + the details of logical replication conflicts. + </para> ... + <term><literal>lsn</literal> (<type>pg_lsn</type>)</term> + <listitem> + <para> + Specifies the commit LSN of the remote transaction whose changes are to be skipped + by the logical replication worker. Skipping + individual subtransactions is not supported. Setting <literal>NONE</literal> + resets the LSN. I think we'll extend the SKIP option choices in the future besides the 'lsn' option. Then, one sentence "After logical replication successfully skips the transaction or commits non-empty transaction, the LSN .. is cleared" should be moved to the explanation for 'lsn' section, if we think this behavior to reset LSN is unique for 'lsn' option ? (2) doc/src/sgml/catalogs.sgml + <row> + <entry role="catalog_table_entry"><para role="column_definition"> + <structfield>subskiplsn</structfield> <type>pg_lsn</type> + </para> + <para> + Commit LSN of the transaction whose changes are to be skipped, if a valid + LSN; otherwise <literal>0/0</literal>. + </para></entry> + </row> + We need to cover the PREPARE that keeps causing errors on the subscriber. This would apply to the entire patch (e.g. the rename of skip_xact_commit_lsn) (3) apply_handle_commit_internal comments /* * Helper function for apply_handle_commit and apply_handle_stream_commit. + * Return true if the transaction was committed, otherwise return false. */ If we want to make the new added line alinged with other functions in worker.c, we should insert one blank line before it ? (4) apply_worker_post_transaction I'm not sure if the current refactoring is good or not. For example, the current HEAD calls pgstat_report_stat(false) for a commit case if we are in a transaction in apply_handle_commit_internal. On the other hand, your refactoring calls pgstat_report_stat unconditionally for apply_handle_commit path. I'm not sure if there are many cases to call apply_handle_commit without opening a transaction, but is that acceptable ? Also, the name is a bit broad. How about making a function only for stopping and resetting LSN at this stage ? (5) comments for clear_subscription_skip_lsn How about changing the comment like below ? From: Clear subskiplsn of pg_subscription catalog To: Clear subskiplsn of pg_subscription catalog with origin state update Best Regards, Takamichi Osumi
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