Re: Introduce XID age and inactive timeout based replication slot invalidation

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation
Date: 2024-03-21 11:20:50
Message-ID: ZfwYEtiHApYpsYj6@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Mar 21, 2024 at 04:13:31PM +0530, Bharath Rupireddy wrote:
> On Thu, Mar 21, 2024 at 3:20 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > > My concern was that we set catalog_xmin at logical slot creation time. So if we
> > > set last_inactive_at to zero at creation time and the slot is not used for a long
> > > period of time > timeout, then I think it's not helping there.
> >
> > But, we do call ReplicationSlotRelease() after slot creation. For
> > example, see CreateReplicationSlot(). So wouldn't that take care of
> > the case you are worried about?
>
> Right. That's true even for pg_create_physical_replication_slot and
> pg_create_logical_replication_slot. AFAICS, setting it to the current
> timestamp in ReplicationSlotRelease suffices unless I'm missing
> something.

Right, but we have:

"
if (set_last_inactive_at &&
slot->data.persistency == RS_PERSISTENT)
{
/*
* There's no point in allowing failover slots to get invalidated
* based on slot's inactive_timeout parameter on standby. The failover
* slots simply get synced from the primary on the standby.
*/
if (!(RecoveryInProgress() && slot->data.failover))
{
SpinLockAcquire(&slot->mutex);
slot->last_inactive_at = GetCurrentTimestamp();
SpinLockRelease(&slot->mutex);
}
}
"

while we set set_last_inactive_at to false at creation time so that last_inactive_at
is not set to GetCurrentTimestamp(). We should set set_last_inactive_at to true
if a timeout is provided during the slot creation.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-03-21 11:23:34 Re: Catalog domain not-null constraints
Previous Message Richard Guo 2024-03-21 11:20:30 Re: Oversight in reparameterize_path_by_child leading to executor crash