| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix temporary WAL receiver slot handling on timeline switches |
| Date: | 2026-08-27 16:19:14 |
| Message-ID: | E1wzcor-00000002Mii-0zDc@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix temporary WAL receiver slot handling on timeline switches
Previously, when wal_receiver_create_temp_slot was enabled, a timeline
switch could cause the walreceiver to try to create the same temporary
replication slot again on the same connection. The slot had already been
created before the first streaming attempt and still existed, so the
second creation attempt failed with a FATAL error such as
"could not create replication slot ...".
The walreceiver would later be restarted and streaming replication could
continue, so this did not permanently break replication. Nevertheless,
the unexpected failure is a bug and should be fixed.
Fix this by tracking whether the temporary replication slot has already
been created for the lifetime of the walreceiver and skipping subsequent
creation attempts. Also copy the retained slot name to shared memory on
each streaming attempt, since RequestXLogStreaming() clears it when
streaming is restarted without a configured primary slot. This also
keeps pg_stat_wal_receiver.slot_name populated after timeline switches.
Backpatch to all supported versions.
Author: ChangAo Chen <cca5507(at)qq(dot)com>
Reviewed-by: Quan Zongliang <quanzongliang(at)yeah(dot)net>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/874c22c94fb459b81d63f98c453ec59e167817e1
Modified Files
--------------
src/backend/replication/walreceiver.c | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-08-27 16:19:24 | pgsql: Fix temporary WAL receiver slot handling on timeline switches |
| Previous Message | Fujii Masao | 2026-08-27 16:19:04 | pgsql: Fix temporary WAL receiver slot handling on timeline switches |