Re: [BUG] "FailedAssertion" reported when streaming in logical replication - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: [BUG] "FailedAssertion" reported when streaming in logical replication
Date
Msg-id CAA4eK1JLSZLrDkF5p8ty6+4Ug=CNeYy2yoJvM_yHiTSWnX6EyQ@mail.gmail.com
Whole thread Raw
In response to Re: [BUG] "FailedAssertion" reported when streaming in logical replication  (Dilip Kumar <dilipbalaut@gmail.com>)
Responses Re: [BUG] "FailedAssertion" reported when streaming in logical replication  (Dilip Kumar <dilipbalaut@gmail.com>)
List pgsql-hackers
On Tue, Apr 27, 2021 at 11:50 AM Dilip Kumar <dilipbalaut@gmail.com> wrote:
>
> On Tue, Apr 27, 2021 at 11:43 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> >
> > On Mon, Apr 26, 2021 at 7:52 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> > >
> > > On Mon, Apr 26, 2021 at 6:59 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> > > >
> > > > On Mon, Apr 26, 2021 at 5:55 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> > > > >
> > > > > I am able to reproduce this and I think I have done the initial investigation.
> > > > >
> > > > > The cause of the issue is that, this transaction has only one change
> > > > > and that change is XLOG_HEAP2_NEW_CID, which is added through
> > > > > SnapBuildProcessNewCid.  Basically, when we add any changes through
> > > > > SnapBuildProcessChange we set the base snapshot but when we add
> > > > > SnapBuildProcessNewCid this we don't set the base snapshot, because
> > > > > there is nothing to be done for this change.  Now, this transaction is
> > > > > identified as the biggest transaction with non -partial changes, and
> > > > > now in ReorderBufferStreamTXN, it will return immediately because the
> > > > > base_snapshot is NULL.
> > > > >
> > > >
> > > > Your analysis sounds correct to me.
> > > >
> > >
> > > Thanks, I have attached a patch to fix this.
> > >
> >
> > Can't we use 'txns_by_base_snapshot_lsn' list for this purpose? It is
> > ensured in ReorderBufferSetBaseSnapshot that we always assign
> > base_snapshot to a top-level transaction if the current is a known
> > subxact. I think that will be true because we always form xid-subxid
> > relation before processing each record in
> > LogicalDecodingProcessRecord.
>
> Yeah, we can do that, but here we are only interested in top
> transactions and this list will give us sub-transaction as well so we
> will have to skip it in the below if condition.
>

I am not so sure about this point. I have explained above why I think
there won't be any subtransactions in this. Can you please let me know
what am I missing if anything?

-- 
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: "tanghy.fnst@fujitsu.com"
Date:
Subject: RE: Truncate in synchronous logical replication failed
Next
From: Dilip Kumar
Date:
Subject: Re: [BUG] "FailedAssertion" reported when streaming in logical replication