Re: Make pg_waldump report replication origin ID, LSN, and timestamp.

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Make pg_waldump report replication origin ID, LSN, and timestamp.
Date: 2021-12-07 00:57:38
Message-ID: CAD21AoAMuTrXezGqaV1Q5H-Hf+zKqGbU8XuCZk9iQMYueF3+8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 6, 2021 at 11:24 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Mon, Dec 6, 2021 at 5:09 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> >
> > On Mon, Dec 06, 2021 at 04:35:07PM +0900, Masahiko Sawada wrote:
> > > I've attached a patch to add replication origin information to
> > > xact_desc_prepare().
> >
> > Yeah.
> >
> > + if (origin_id != InvalidRepOriginId)
> > + appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
> > + origin_id,
> > + LSN_FORMAT_ARGS(parsed.origin_lsn),
> > + timestamptz_to_str(parsed.origin_timestamp));
> >
> > Shouldn't you check for parsed.origin_lsn instead? The replication
> > origin is stored there as far as I read EndPrepare().
>
> Yeah, I was thinking check origin_lsn instead. That way, we don't show
> invalid origin_timestamp and origin_lsn even if origin_id is set. But
> as far as I read, the same is true for xact_desc_commit() (and
> xact_desc_rollback()). That is, since apply workers always its origin
> id and could do commit transactions that are not replicated from the
> publisher, it's possible that xact_desc_commit() reports like:
>
> rmgr: Transaction len (rec/tot): 117/ 117, tx: 725, lsn:
> 0/014BE938, prev 0/014BE908, desc: COMMIT 2021-12-06 22:04:44.462200
> JST; inval msgs: catcache 55 catcache 54 catcache 64; origin: node 1,
> lsn 0/0, at 2000-01-01 09:00:00.000000 JST

Hmm, is that okay in the first place? This happens since the apply
worker updates twophaesstate value of pg_subscription after setting
the origin id and before entering the apply loop. No changes in this
transaction will be replicated but an empty transaction that has
origin id and doesn't have origin lsn and time will be replicated.

Regards,

--
Masahiko Sawada
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2021-12-07 00:58:00 Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
Previous Message Ashutosh Sharma 2021-12-07 00:52:34 Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints