Re: Error "initial slot snapshot too large" in create replication slot - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: Error "initial slot snapshot too large" in create replication slot
Date
Msg-id CAFiTN-s_PYicXeb6+uZkERqATpZLzpfsg0qP6G_GMPhu=rgxUA@mail.gmail.com
Whole thread Raw
In response to Re: Error "initial slot snapshot too large" in create replication slot  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: Error "initial slot snapshot too large" in create replication slot  (Yura Sokolov <y.sokolov@postgrespro.ru>)
List pgsql-hackers
On Mon, Jan 31, 2022 at 11:50 AM Kyotaro Horiguchi
<horikyota.ntt@gmail.com> wrote:
>
> At Mon, 17 Jan 2022 09:27:14 +0530, Dilip Kumar <dilipbalaut@gmail.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.


-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: Synchronizing slots from primary to standby
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: [PATCH] Accept IP addresses in server certificate SANs