Re: Catalog_xmin is not advanced when a logical slot is lost - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Catalog_xmin is not advanced when a logical slot is lost
Date
Msg-id 20221121160510.bysegh7omvyvwzqt@alvherre.pgsql
Whole thread Raw
In response to Re: Catalog_xmin is not advanced when a logical slot is lost  (sirisha chamarthi <sirichamarthi22@gmail.com>)
Responses Re: Catalog_xmin is not advanced when a logical slot is lost
List pgsql-hackers
On 2022-Nov-21, sirisha chamarthi wrote:

> > > I am a fan of stricter, all-assumption-covering conditions. In case we
> > > don't want to check restart_lsn, an Assert might be useful to validate
> > > our assumption.
> >
> > Agreed.  I'll throw in an assert.
> 
> Changed this in the patch to throw an assert.

Thank you.  I had pushed mine for CirrusCI to test, and it failed the
assert I added in slot.c:
https://cirrus-ci.com/build/4786354503548928
Not yet sure why, looking into it.

You didn't add any asserts to the slot.c code.

In slotfuncs.c, I'm not sure I want to assert anything about restart_lsn
in any cases other than when invalidated_at is set.  In other words, I
prefer this coding in pg_get_replication_slots:

        if (!XLogRecPtrIsInvalid(slot_contents.data.invalidated_at))
        {
            Assert(XLogRecPtrIsInvalid(slot_contents.data.restart_lsn));
            walstate = WALAVAIL_REMOVED;
        }
        else
            walstate = GetWALAvailability(slot_contents.data.restart_lsn);


Your proposal is doing this:

        switch (walstate)
        {
            [...]
            case WALAVAIL_REMOVED:

                if (!XLogRecPtrIsInvalid(slot_contents.data.restart_lsn))
                {
                    [...]
                    if (pid != 0)
                        [...] break;
                }
                Assert(XLogRecPtrIsInvalid(slot_contents.data.restart_lsn));

which sounds like it could be hit if the replica is connected to the
slot.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: allowing for control over SET ROLE
Next
From: Jakub Wartak
Date:
Subject: Re: Damage control for planner's get_actual_variable_endpoint() runaway