postgres-github.git / summary / log / commit / refs

commit    7f469097c72e6f8988024eb9bc1b417bfeb29fd9
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Fri May 22 19:04:26 2026 +0000

    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