Re: Review for GetWALAvailability()

Alvaro Herrera <alvherre@2ndquadrant.com>

From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
Date: 2020-06-17T18:50:14Z
Lists: pgsql-hackers
On 2020-Jun-17, Kyotaro Horiguchi wrote:

> @@ -342,7 +351,14 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
>  		else
>  			nulls[i++] = true;
>  
> -		walstate = GetWALAvailability(slot_contents.data.restart_lsn);
> +		/* use last_invalidated_lsn when the slot is invalidated */
> +		if (XLogRecPtrIsInvalid(slot_contents.data.restart_lsn))
> +			targetLSN = slot_contents.last_invalidated_lsn;
> +		else
> +			targetLSN = slot_contents.data.restart_lsn;
> +
> +		walstate = GetWALAvailability(targetLSN, last_removed_seg,
> +									  slot_contents.active_pid != 0);

Yeah, this approach seems better overall.  I'll see if I can get this
done after lunch.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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.