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-23 11:50:19
Message-ID: bb286c1c536866fc3b18f632dc90ee10@stjohn.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

It seems starting the stream early introduced more problems than it was
solving.

Here's v5 - reverting back to v3 but adding a recreation function for
those cases where the slot gets invalidated due to
max_slot_wal_keep_size. Also should fix failed backup, lingering slots -
errors, with the atexit function that was there in v3. It should also
work with replicas.

This v5 does not handle any v18 idle_replication_slot_timeout errors.
But it seems that in master today, a previously created slot which would
be specified by --slot and not --create-slot could also be invalidated
if a tiny idle_replication_slot_timeout is set. If I'm not wrong, does a
pre-base-backup slot creation count as a regression?

Would it make sense to make READ_REPLICATION_SLOT return NULL for
restart_lsn instead of the restart_lsn even though the slot is
invalidated? In that case my recreation-function would also handle
those. That would be a separate server-side patch though.

Thanks for the feedback and reviews!

//Jesper

On 2026-11-20 23:59, Zsolt Parragi wrote:
> This seems to break rebuilding cascading standbys: from the
> intermediate standby, reusing its existing slot (casc stopped, then
> pg_basebackup -h stby -S casc -X stream -R --checkpoint=fast):
>
> master client: stby redo=0/03000028 slot=0/08000060 -> rc=0
> patched client: stby redo=0/08000060 slot=0/0D000000 -> rc=1
> pg_basebackup: error: backup start point 0/08000060 is older than the
> start of the WAL stream at 0/0D000000
>
> And from my previous email:
>
>> and can be invalidated based on max_slot_wal_keep_size
>
> still holds with --checkpoint=false (it works with spread)
>
> And another new issue is that now a failed backup can leave the
> created slot on the server:
>
> pg_basebackup -D x -X stream -C -S s1 --manifest-checksums=bogus
> pg_basebackup -D x -X stream -C -S s1
>
> --> ERROR: replication slot "s1" already exists

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message vignesh C 2026-11-23 12:42:08 Re: Logical replication commits duplicates in DEFERRABLE unique indexes
Previous Message Nitin Motiani 2026-11-23 11:40:04 Re: BUG #19931: postgres_fdw: FOR UPDATE over a pushed-down join ignores a pseudoconstant qual