pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix temporary WAL receiver slot handling on timeline switches
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:18 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/58ff54aee8b252b23b35c7a6297bf9189731bca3

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:18 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/764d31b8ae360685b06913c7c6195ec1bfefcd33

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:18 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2bf6144b4e8f806f9a6934a5af3999c65b3504ff

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:18 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4c8fa02c5feaf7dc9be85da06987836777cd34fe

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:19 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/58fb12f4aabe4e861460ad316a9168d90d85353a

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 +++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 43 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:19 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix temporary WAL receiver slot handling on timeline switches
@ 2026-08-27 16:19 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Fujii Masao @ 2026-08-27 16:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/aec25d6107ddf03430947f67d662bdedffc064c2

Modified Files
--------------
src/backend/replication/walreceiver.c      | 23 ++++++++++-----
src/test/recovery/t/004_timeline_switch.pl | 46 +++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-08-27 16:19 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 16:18 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:18 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:18 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:18 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:19 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:19 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>
2026-08-27 16:19 pgsql: Fix temporary WAL receiver slot handling on timeline switches Fujii Masao <fujii@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox