Walreceiver create temp slot more than once when timeline switch - Mailing list pgsql-hackers

From cca5507
Subject Walreceiver create temp slot more than once when timeline switch
Date
Msg-id tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com
Whole thread
Responses Re: In core use of RegisterXactCallback() and RegisterSubXactCallback()
List 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:
replicationslot "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

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: toast table corrupted by vacuum - missing chunk number 0 for toast value
Next
From: Mihail Nikalayeu
Date:
Subject: Apply worker can pick an invalid index for REPLICA IDENTITY FULL lookups