aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-03-05 10:17:39 +0900
committerMichael Paquier <michael@paquier.xyz>2025-03-05 10:17:39 +0900
commitf4694e0f35b218238cbc87bcf8f8f5c6639bb1d4 (patch)
tree58fc05ad2d329321698ade9f0360faaffecb4589 /src/backend/replication
parent54d23601b978d2552696fb7fe35ae5d6102ea2cb (diff)
downloadpostgresql-f4694e0f35b218238cbc87bcf8f8f5c6639bb1d4.tar.gz
postgresql-f4694e0f35b218238cbc87bcf8f8f5c6639bb1d4.zip
Fix some gaps in pg_stat_io with WAL receiver and WAL summarizer
The WAL receiver and WAL summarizer processes gain each one a call to pgstat_report_wal(), to make sure that they report their WAL statistics to pgstats, gathering data for pg_stat_io. In the WAL receiver, the stats reports are timed with status updates sent to the primary, that depend on wal_receiver_status_interval and wal_receiver_timeout. This is a conservative choice, but perhaps we could be more aggressive with the frequency of the stats reports. An interesting historical fact is that the WAL receiver does writes and syncs of WAL, but it has never reported its statistics to pgstats in pg_stat_wal. In the WAL summarizer, the stats reports are done each time the process waits for WAL. While on it, pg_stat_io is adjusted so as these two processes do not report any rows when IOObject is not WAL, making the view easier to use with less rows. Two tests are added in TAP, checking statistics for the WAL summarizer and the WAL receiver. Status updates in the WAL receiver are currently possible in the recovery test 001_stream_rep.pl. Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/Z8UKZyVSHUUQJHNb@paquier.xyz
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/walreceiver.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 82f7302ff9f..83129cb92af 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -584,6 +584,16 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
bool requestReply = false;
/*
+ * Report pending statistics to the cumulative stats
+ * system. This location is useful for the report as it
+ * is not within a tight loop in the WAL receiver, to
+ * avoid bloating pgstats with requests, while also making
+ * sure that the reports happen each time a status update
+ * is sent.
+ */
+ pgstat_report_wal(false);
+
+ /*
* Check if time since last receive from primary has
* reached the configured limit.
*/