summaryrefslogtreecommitdiff
path: root/src/backend/utils/activity/pgstat_wal.c
diff options
context:
space:
mode:
authorMichael Paquier2025-03-11 00:04:11 +0000
committerMichael Paquier2025-03-11 00:04:11 +0000
commit76def4cdd7c2b32d19e950a160f834392ea51744 (patch)
tree8996570dd7e4c2b4fd9aa9cbffd2fff97ec3fb01 /src/backend/utils/activity/pgstat_wal.c
parent59a1592e39fed164d4d6437d62a55aef36e866a5 (diff)
Add WAL data to backend statistics
This commit adds per-backend WAL statistics, providing the same information as pg_stat_wal, except that it is now possible to know how much WAL activity is happening in each backend rather than an overall aggregate of all the activity. Like pg_stat_wal, the implementation relies on pgWalUsage, tracking the difference of activity between two reports to pgstats. This data can be retrieved with a new system function called pg_stat_get_backend_wal(), that returns one tuple based on the PID provided in input. Like pg_stat_get_backend_io(), this is useful when joined with pg_stat_activity to get a live picture of the WAL generated for each running backend, showing how the activity is [un]balanced. pgstat_flush_backend() gains a new flag value, able to control the flush of the WAL stats. This commit relies mostly on the infrastructure provided by 9aea73fc61d4, that has introduced backend statistics. Bump catalog version. A bump of PGSTAT_FILE_FORMAT_ID is not required, as backend stats do not persist on disk. Author: Bertrand Drouvot <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Reviewed-by: Nazir Bilal Yavuz <[email protected]> Reviewed-by: Xuneng Zhou <[email protected]> Discussion: https://postgr.es/m/Z3zqc4o09dM/[email protected]
Diffstat (limited to 'src/backend/utils/activity/pgstat_wal.c')
-rw-r--r--src/backend/utils/activity/pgstat_wal.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/activity/pgstat_wal.c
index 5d3da4b674e..16a1ecb4d90 100644
--- a/src/backend/utils/activity/pgstat_wal.c
+++ b/src/backend/utils/activity/pgstat_wal.c
@@ -52,6 +52,7 @@ pgstat_report_wal(bool force)
/* flush wal stats */
(void) pgstat_wal_flush_cb(nowait);
+ pgstat_flush_backend(nowait, PGSTAT_BACKEND_FLUSH_WAL);
/* flush IO stats */
pgstat_flush_io(nowait);