From 6b9e875f7286d8535bff7955e5aa3602e188e436 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 9 Mar 2019 10:45:17 -0800 Subject: Track block level checksum failures in pg_stat_database This adds a column that counts how many checksum failures have occurred on files belonging to a specific database. Both checksum failures during normal backend processing and those created when a base backup detects a checksum failure are counted. Author: Magnus Hagander Reviewed by: Julien Rouhaud --- src/include/pgstat.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/include/pgstat.h') diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 88a75fb798..725c8b0d64 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -64,7 +64,8 @@ typedef enum StatMsgType PGSTAT_MTYPE_FUNCPURGE, PGSTAT_MTYPE_RECOVERYCONFLICT, PGSTAT_MTYPE_TEMPFILE, - PGSTAT_MTYPE_DEADLOCK + PGSTAT_MTYPE_DEADLOCK, + PGSTAT_MTYPE_CHECKSUMFAILURE } StatMsgType; /* ---------- @@ -530,6 +531,18 @@ typedef struct PgStat_MsgDeadlock Oid m_databaseid; } PgStat_MsgDeadlock; +/* ---------- + * PgStat_MsgChecksumFailure Sent by the backend to tell the collector + * about checksum failures noticed. + * ---------- + */ +typedef struct PgStat_MsgChecksumFailure +{ + PgStat_MsgHdr m_hdr; + Oid m_databaseid; + int m_failurecount; +} PgStat_MsgChecksumFailure; + /* ---------- * PgStat_Msg Union over all possible messages. @@ -593,6 +606,7 @@ typedef struct PgStat_StatDBEntry PgStat_Counter n_temp_files; PgStat_Counter n_temp_bytes; PgStat_Counter n_deadlocks; + PgStat_Counter n_checksum_failures; PgStat_Counter n_block_read_time; /* times in microseconds */ PgStat_Counter n_block_write_time; @@ -1200,6 +1214,8 @@ extern void pgstat_report_analyze(Relation rel, extern void pgstat_report_recovery_conflict(int reason); extern void pgstat_report_deadlock(void); +extern void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount); +extern void pgstat_report_checksum_failure(void); extern void pgstat_initialize(void); extern void pgstat_bestart(void); -- cgit v1.2.3