Re: Timing issue in pg_basebackup

From: Jesper St John <jesper(at)stjohn(dot)se>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Jesper St John <admin(at)zonezero(dot)se>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Magnus Hagander <magnus(at)hagander(dot)net>, Kirill Reshke <reshkekirill(at)gmail(dot)com>
Subject: Re: Timing issue in pg_basebackup
Date: 2026-11-25 14:33:48
Message-ID: 3c8f821f1a210dd19dd16e4370077364@stjohn.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Here's a v6 patch.

On 2026-11-24 23:11, Zsolt Parragi wrote:
> On Tue, 24 Nov 2026, Jesper St John <jesper(at)stjohn(dot)se> wrote:
>> What if we create a temp slot before running base backup and then drop
>> it and create a new slot if needed as it is done today? That way it
>> shouldn't be hit by idle_replication_slot_timeout and any
>> sigint/sigterm
>> would not leave the slot behind.
>>
>> The patch might be smaller...
>
> That could work. The main downside is that for a short time, this
> needs 2 replication slots, so that would need some documentation. I
> think that approach will also leave a few very unlikely races where we
> could still hit the original issue, but unless I'm wrong, that should
> be very unlikely to happen in practice.

It didn't get smaller, but I think it's easier to read. There might be a
race between dropping the temp slot and creating a regular slot but it
should be minimal.

>
>>
>> The idle_session_timeout of something smaller than the time it takes
>> to
>> do checkpoint=spread would probably recreate the timing issue with
>> temp
>> slot- so perhaps that could be overriden?
>>
>
> Yes, that could work too. But we can't override
> idle_replication_slot_timeout, but that requires a somewhat
> misconfigured server.

idle_session_timeout is now set to 0 on the connection, so that the temp
slot is kept.

//Jesper

Attachment Content-Type Size
v6-0001-pg_basebackup-Create-the-WAL-streaming-slot-befor.patch text/x-diff 25.5 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Zsolt Parragi 2026-11-25 11:32:10 Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"