Add last failed connection error message to pg_stat_wal_receiver

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Add last failed connection error message to pg_stat_wal_receiver
Date: 2022-05-02 07:57:16
Message-ID: CALj2ACWt6wkFnu7sac3pUb4WLZ3jA1m3cu7FJE3EovpGKzhwKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In production environments WAL receiver connection attempts to primary
may fail for many reasons (primary down, network is broken,
authentication tokens changes, primary_conn_info modifications, socket
errors and so on.). Although we emit the error message to server logs,
isn't it useful to show the last connection error message via
pg_stat_wal_receiver or pg_stat_get_wal_receiver? This will be super
helpful in production environments to analyse what the WAL receiver
issues as accessing and sifting through server logs can be quite
cumbersome for the end users.

Thoughts?

Attached patch can only display the last_conn_error only after the WAL
receiver is up, but it will be good to let pg_stat_wal_receiver emit
last_conn_error even before that. Imagine WAL receiver is continuously
failing on the standby, if we let pg_stat_wal_receiver report
last_conn_error, all other columns will show NULL. I can change this
way, if others are okay with it.

Regards,
Bharath Rupireddy.

Attachment Content-Type Size
v1-0001-Add-last-failed-connection-error-message-to-pg_st.patch application/octet-stream 7.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2022-05-02 08:25:31 Re: postgres_fdw: commit remote (sub)transactions in parallel during pre-commit
Previous Message Michael Paquier 2022-05-02 07:00:53 Re: Rewriting the test of pg_upgrade as a TAP test - take three - remastered set