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: v1-0001-Fix-walreceiver-create-temp-slot-more-than-once-w.patch
Description: Binary data

Reply via email to