Re: [PATCH] Allow to specify restart_lsn in pg_create_physical_replication_slot()

From: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Vyacheslav Makarov <v(dot)makarov(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Allow to specify restart_lsn in pg_create_physical_replication_slot()
Date: 2020-06-26 21:08:03
Message-ID: f7e72a089ada10dcdf25ca1e00c7ca6e@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-06-23 04:18, Michael Paquier wrote:
> On Mon, Jun 22, 2020 at 08:18:58PM +0300, Alexey Kondratov wrote:
>> Things get worse when we allow specifying an older LSN, since it has a
>> higher chances to be at the horizon of deletion by checkpointer.
>> Anyway, if
>> I get it correctly, with a current patch slot will be created
>> successfully,
>> but will be obsolete and should be invalidated by the next checkpoint.
>
> Is that a behavior acceptable for the end user? For example, a
> physical slot that is created to immediately reserve WAL may get
> invalidated, causing it to actually not keep WAL around contrary to
> what the user has wanted the command to do.
>

I can imagine that it could be acceptable in the initially proposed
scenario for someone, since creation of a slot with historical
restart_lsn is already unpredictable — required segment may exist or may
do not exist. However, adding here an undefined behaviour even after a
slot creation does not look good to me anyway.

I have looked closely on the checkpointer code and another problem is
that it decides once which WAL segments to delete based on the
replicationSlotMinLSN, and does not check anything before the actual
file deletion. That way the gap for a possible race is even wider. I do
not know how to completely get rid of this race without introducing of
some locking mechanism, which may be costly.

Thanks for feedback
--
Alexey Kondratov

Postgres Professional https://www.postgrespro.com
Russian Postgres Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2020-06-26 21:18:58 Re: should libpq also require TLSv1.2 by default?
Previous Message Peter Geoghegan 2020-06-26 20:53:05 Re: Default setting for enable_hashagg_disk