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 <[email protected]> Author: Michael Paquier <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7f469097c72e6f8988024eb9bc1b417bfeb29fd9 Modified Files -------------- src/backend/replication/walreceiver.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
