Walreceiver create temp slot more than once when timeline switch

From: cca5507 <cca5507(at)qq(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Walreceiver create temp slot more than once when timeline switch
Date: 2026-08-22 15:12:26
Message-ID: tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Steps to repro
==============

1) start a primary and do a basebackup

initdb -D primary -c wal_receiver_create_temp_slot=on -c port=5432
pg_ctl -D primary -l primary.log start
pg_basebackup -D standby -R -p 5432

2) increase the timeline of primary

touch primary/standby.signal
pg_ctl -D primary -l primary.log restart
pg_ctl -D primary -l primary.log promote

3) start the standby

pg_ctl -D standby -l standby.log start -o "-c port=5433"

Logs of standby
===============

2026-08-22 22:59:08.663 CST [49194] LOG: started streaming WAL from primary at 0/03000000 on timeline 1
2026-08-22 22:59:08.674 CST [49194] LOG: replication terminated by primary server
2026-08-22 22:59:08.674 CST [49194] DETAIL: End of WAL reached on timeline 1 at 0/03052948.
2026-08-22 22:59:08.677 CST [49193] LOG: new target timeline is 2
2026-08-22 22:59:08.677 CST [49193] LOG: invalid record length at 0/03052948: expected at least 24, got 0
2026-08-22 22:59:08.678 CST [49194] FATAL: could not create replication slot "pg_walreceiver_49195": ERROR: replication slot "pg_walreceiver_49195" already exists
2026-08-22 22:59:08.682 CST [49196] LOG: started streaming WAL from primary at 0/03000000 on timeline 2

Fix
===

Make sure that the walreceiver creates temp slot only once.

Thoughts?

--
Regards,
ChangAo Chen

Attachment Content-Type Size
v1-0001-Fix-walreceiver-create-temp-slot-more-than-once-w.patch application/octet-stream 2.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2026-08-22 16:22:31 RE: Race conditions in logical decoding
Previous Message Pavel Stehule 2026-08-22 14:25:16 Re: toast table corrupted by vacuum - missing chunk number 0 for toast value