Re: Add the replication origin name and commit-LSN to logical replication worker errcontext

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add the replication origin name and commit-LSN to logical replication worker errcontext
Date: 2022-03-04 05:54:53
Message-ID: CAA4eK1+wMB_e60F2EfmW65gxO5uhfH9j91efhXiKLeOU9aoNKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 4, 2022 at 6:40 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> Attached updated version patches.
>

The patch looks mostly good to me. Few minor comments:
1. I think we can have an Assert for errarg->origin_name in
apply_error_callback after checking the command as this function
assumes that it will always be set.
2. I suggest minor changes in the documentation change:
When a conflict produces an error, the replication won't proceed, and
the apply worker will emit the following kind of message to the
subscriber's server log:
+<screen>
+ERROR: duplicate key value violates unique constraint "test_pkey"
+DETAIL: Key (c)=(1) already exists.
+CONTEXT: processing remote data during "INSERT" for replication
target relation "public.test" in transaction 725 committed at LSN
0/14BFA88 from replication origin "pg_16395"
+</screen>

The LSN of the transaction that contains the change violating the
constraint and the replication origin name can be found from the
server log (LSN 0/14C0378 and replication origin
<literal>pg_16395</literal> in the above case). To skip the
transaction, the subscription needs to be disabled temporarily by
<command>ALTER SUBSCRIPTION ... DISABLE</command> first. Then, the
transaction can be skipped by calling the <link
linkend="pg-replication-origin-advance">
<function>pg_replication_origin_advance()</function></link> function
with the <parameter>node_name</parameter> (i.e.,
<literal>pg_16395</literal>) and the next LSN of the commit LSN (i.e.,
LSN 0/14C0379).

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-03-04 05:56:20 Re: Add the replication origin name and commit-LSN to logical replication worker errcontext
Previous Message Dilip Kumar 2022-03-04 05:37:19 Re: Make relfile tombstone files conditional on WAL level