Re: Error "initial slot snapshot too large" in create replication slot

From: Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: Julien Rouhaud <rjuju123(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Error "initial slot snapshot too large" in create replication slot
Date: 2022-02-13 14:35:38
Message-ID: 755c7bb23ad97a4a5319ebd13cdf8afccf5f05ed.camel@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

В Пн, 07/02/2022 в 13:52 +0530, Dilip Kumar пишет:
> On Mon, Jan 31, 2022 at 11:50 AM Kyotaro Horiguchi
> <horikyota(dot)ntt(at)gmail(dot)com> wrote:
> > At Mon, 17 Jan 2022 09:27:14 +0530, Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote in
> >
> > me> Mmm. The size of the array cannot be larger than the numbers the
> > me> *Connt() functions return. Thus we cannot attach the oversized array
> > me> to ->subxip. (I don't recall clearly but that would lead to assertion
> > me> failure somewhere..)
> >
> > Then, I fixed the v3 error and post v4.
>
> Yeah you are right, SetTransactionSnapshot() has that assertion.
> Anyway after looking again it appears that
> GetMaxSnapshotSubxidCount is the correct size because this is
> PGPROC_MAX_CACHED_SUBXIDS +1, i.e. it considers top transactions as
> well so we don't need to add them separately.
>
> > SnapBUildInitialSnapshot tries to store XIDS of both top and sub
> > transactions into snapshot->xip array but the array is easily
> > overflowed and CREATE_REPLICATOIN_SLOT command ends with an error.
> >
> > To fix this, this patch is doing the following things.
> >
> > - Use subxip array instead of xip array to allow us have larger array
> > for xids. So the snapshot is marked as takenDuringRecovery, which
> > is a kind of abuse but largely reduces the chance of getting
> > "initial slot snapshot too large" error.
>
> Right. I think the patch looks fine to me.
>

Good day.

I've looked to the patch. Personally I'd prefer dynamically resize
xip array. But I think there is issue with upgrade if replica source
is upgraded before destination, right?

Concerning patch, I think more comments should be written about new
usage case for `takenDuringRecovery`. May be this field should be renamed
at all?

And there are checks for `takenDuringRecovery` in `heapgetpage` and
`heapam_scan_sample_next_tuple`. Are this checks affected by the change?
Neither the preceding discussion nor commit message answer me.

-------

regards

Yura Sokolov
Postgres Professional
y(dot)sokolov(at)postgrespro(dot)ru
funny(dot)falcon(at)gmail(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joseph Koshakow 2022-02-13 14:35:47 Re: Fix overflow in DecodeInterval
Previous Message Dmitry Dolgov 2022-02-13 14:33:13 Re: Avoiding smgrimmedsync() during nbtree index builds