Re: Non-reserved replication slots and slot advancing

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>, pgsql-hackers@postgresql.org, petr@2ndquadrant.com, simon@2ndQuadrant.com
Date: 2018-07-10T07:26:30Z
Lists: pgsql-hackers
Hi,

On 2018-07-10 09:54:28 +0900, Michael Paquier wrote:
> > > Also, ERRCODE_FEATURE_NOT_SUPPORTED doesn't quite seem right. How about
> > > ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE?
> > 
> > +1 to both of Andres' suggestions.
> 
> Those indeed sound better.  What do you think of the attached?

Looks generally good. One remark:

> +	/* A slot whose restart_lsn has never been reserved cannot be advanced */
> +	if (XLogRecPtrIsInvalid(MyReplicationSlot->data.restart_lsn))
> +	{
> +		ReplicationSlotRelease();
> +		ereport(ERROR,
> +				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> +				 errmsg("cannot advance replication slot that has not previously reserved WAL")));
> +	}

Why is the ReplicationSlotRelease() needed here? Souldn't the error
handling code do so automatically?

Greetings,

Andres Freund


Commits

  1. Block replication slot advance for these not yet reserving WAL