]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Improve pg_stat_wal_receiver for CONNECTING status
authorMichael Paquier <michael@paquier.xyz>
Fri, 22 May 2026 19:04:26 +0000 (04:04 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 22 May 2026 19:04:26 +0000 (04:04 +0900)
commit7f469097c72e6f8988024eb9bc1b417bfeb29fd9
tree8a388cfb23525573f4a0488acf1c3db42552c66f
parent06a5c3cdef024630aef0992bb7b471459aa2b70f
Improve pg_stat_wal_receiver for CONNECTING status

Commit a36164e7465 added a CONNECTING status for the WAL receiver, but
pg_stat_wal_receiver returned no information while the connection to the
primary was attempted, limiting the usability of the feature in
high-latency environments where the connection attempt to the primary
could take time.

This commit improves the report of the status by splitting the way the
shared memory state of the WAL receiver is filled before and after the
connection to the primary is attempted with walrcv_connect():
- Before the attempt, reset all the connection fields, switch
ready_to_display to true.
- After the attempt, fill in the connection fields.

This change means two spinlock acquisitions instead of one, but at least
monitoring tools can know about the connection attempt before its
completion, enlarging the usability of the feature.  This code path is
taken only once when a WAL receiver is spawned, so the extra acquisition
does not matter performance-wise.

Reported-by: Chao Li <li.evan.chao@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/EF91FF76-1E2B-4F3B-9162-290B4DC517FF@gmail.com
src/backend/replication/walreceiver.c