Re: Review for GetWALAvailability()

Kyotaro Horiguchi <horikyota.ntt@gmail.com>

From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: masao.fujii@oss.nttdata.com
Cc: alvherre@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
Date: 2020-06-18T07:32:59Z
Lists: pgsql-hackers
At Thu, 18 Jun 2020 14:54:47 +0900, Fujii Masao <masao.fujii@oss.nttdata.com> wrote in 
> Sorry, this caused compiler failure. So I fixed that and
> attached the updated version of the patch.

At Thu, 18 Jun 2020 14:40:55 +0900, Fujii Masao <masao.fujii@oss.nttdata.com> wrote in 
> > + errmsg("replication slot \"%s\" does not exist", name)));
> > The error message is not right when the given slot doesn't match the
> > given name.
> 
> This doesn't happen after applying Alvaro's patch.

If name is specified (so slot is NULL) to
ReplicationSlotAcquireInternal and the slot is not found, the ereport
in following code dereferences NULL.

====
    if (s == NULL || !s->in_use)
    {
        LWLockRelease(ReplicationSlotControlLock);

        if (behavior == SAB_Inquire)
            return -1;
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("replication slot \"%s\" does not exist",
                        name ? name : NameStr(slot->data.name))));
    }
====

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



Commits

  1. Persist slot invalidation correctly

  2. Adjust max_slot_wal_keep_size behavior per review

  3. Save slot's restart_lsn when invalidated due to size

  4. Fix issues in invalidation of obsolete replication slots.