Re: Physical replication slot advance is not persistent

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, dim(at)tapoueh(dot)org, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Physical replication slot advance is not persistent
Date: 2020-07-09 10:42:49
Message-ID: CAA4eK1Ltr8EwRQqzzNu8qogLN0HcMdx90drHcC1mncyRWA4-qA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 19, 2020 at 12:16 AM Alexey Kondratov
<a(dot)kondratov(at)postgrespro(dot)ru> wrote:
>
> On 2020-06-16 10:27, Michael Paquier wrote:
> > On Wed, Jun 10, 2020 at 08:57:17PM +0300, Alexey Kondratov wrote:
> >> New test reproduces this issue well. Left it running for a couple of
> >> hours
> >> in repeat and it seems to be stable.
> >
> > Thanks for testing. I have been thinking about the minimum xmin and
> > LSN computations on advancing, and actually I have switched the
> > recomputing to be called at the end of pg_replication_slot_advance().
> > This may be a waste if no advancing is done, but it could also be an
> > advantage to enforce a recalculation of the thresholds for each
> > function call. And that's more consistent with the slot copy, drop
> > and creation.
> >
>
> Sorry for a bit late response, but I see a couple of issues with this
> modified version of the patch in addition to the waste call if no
> advancing is done, mentioned by you:
>
> 1. Both ReplicationSlotsComputeRequiredXmin() and
> ReplicationSlotsComputeRequiredLSN() may have already been done in the
> LogicalConfirmReceivedLocation() if it was a logical slot.
>

I think it is not done in all cases, see the else part in
LogicalConfirmReceivedLocation.

LogicalConfirmReceivedLocation
{
..
else
{
SpinLockAcquire(&MyReplicationSlot->mutex);
MyReplicationSlot->data.confirmed_flush = lsn;
SpinLockRelease(&MyReplicationSlot->mutex);
}
..
}

>
> However, just noted that LogicalConfirmReceivedLocation() only does
> ReplicationSlotsComputeRequiredLSN() if updated_xmin flag was set, which
> looks wrong from my perspective, since updated_xmin and updated_restart
> flags are set separately.
>

I see your point but it is better to back such a change by some test case.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2020-07-09 10:45:58 Re: Performing partition pruning using row value
Previous Message Bharath Rupireddy 2020-07-09 10:33:42 Re: [PATCH] Performance Improvement For Copy From Binary Files