Re: Fix pg_stat_wal_receiver to show CONNECTING status

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Subject: Re: Fix pg_stat_wal_receiver to show CONNECTING status
Date: 2026-05-20 04:10:33
Message-ID: ag00OeH1sbt5ie_6@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 20, 2026 at 09:47:40AM +0800, Chao Li wrote:
> I just read v2, and it is actually the first solution I tried. The
> reason I gave up on that approach and switched to the implementation
> in v1 is that it may wrongly report last_msg_send_time,
> last_msg_receipt_time, and latest_end_time.

As of the code, we have the following at the top of WalReceiverMain()
before the first connection attempt:
/* Initialise to a sanish value */
now = GetCurrentTimestamp();
walrcv->lastMsgSendTime =
walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = now;

And the state of v2 is actually fine, because we finish by reporting
in the SQL calls values that represent the state the WAL receiver is
initialized at based on what the code does. It would be IMO an issue
to hide this information, as they can offer hits about the moment when
we've begun a connection.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-05-20 04:49:03 Re: Fix incorrect size check in statext_dependencies_deserialize
Previous Message shveta malik 2026-05-20 04:07:39 Re: Improve conflict detection when replication origins are reused