summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2012-01-26 15:58:19 +0100
committerMagnus Hagander <magnus@hagander.net>2012-01-26 15:58:19 +0100
commit61cb8c5abb9235c3106af6c6a6e60d94cb1eee80 (patch)
treea15bff3458b883beee010a9cc111e2c3b63bbf51 /src/include
parent0e549697d1c6b8eeb623c497dc38a5aed4deea1e (diff)
Add deadlock counter to pg_stat_database
Adds a counter that tracks number of deadlocks that occurred in each database to pg_stat_database. Magnus Hagander, reviewed by Jaime Casanova
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_proc.h2
-rw-r--r--src/include/pgstat.h19
3 files changed, 20 insertions, 3 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index cbce29ca697..87c6c20dd4a 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201201261
+#define CATALOG_VERSION_NO 201201262
#endif
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 6b121735f9c..ba4f5b60345 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -2634,6 +2634,8 @@ DATA(insert OID = 3069 ( pg_stat_get_db_conflict_startup_deadlock PGNSP PGUID 1
DESCR("statistics: recovery conflicts in database caused by buffer deadlock");
DATA(insert OID = 3070 ( pg_stat_get_db_conflict_all PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_conflict_all _null_ _null_ _null_ ));
DESCR("statistics: recovery conflicts in database");
+DATA(insert OID = 3152 ( pg_stat_get_db_deadlocks PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_deadlocks _null_ _null_ _null_ ));
+DESCR("statistics: deadlocks detected in database");
DATA(insert OID = 3074 ( pg_stat_get_db_stat_reset_time PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 1184 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_stat_reset_time _null_ _null_ _null_ ));
DESCR("statistics: last reset for a database");
DATA(insert OID = 3150 ( pg_stat_get_db_temp_files PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_temp_files _null_ _null_ _null_ ));
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index e91a0e8d89c..1281bd8b69f 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -48,7 +48,8 @@ typedef enum StatMsgType
PGSTAT_MTYPE_FUNCSTAT,
PGSTAT_MTYPE_FUNCPURGE,
PGSTAT_MTYPE_RECOVERYCONFLICT,
- PGSTAT_MTYPE_TEMPFILE
+ PGSTAT_MTYPE_TEMPFILE,
+ PGSTAT_MTYPE_DEADLOCK
} StatMsgType;
/* ----------
@@ -462,6 +463,17 @@ typedef struct PgStat_MsgFuncpurge
Oid m_functionid[PGSTAT_NUM_FUNCPURGE];
} PgStat_MsgFuncpurge;
+/* ----------
+ * PgStat_MsgDeadlock Sent by the backend to tell the collector
+ * about a deadlock that occurred.
+ * ----------
+ */
+typedef struct PgStat_MsgDeadlock
+{
+ PgStat_MsgHdr m_hdr;
+ Oid m_databaseid;
+} PgStat_MsgDeadlock;
+
/* ----------
* PgStat_Msg Union over all possible messages.
@@ -485,6 +497,7 @@ typedef union PgStat_Msg
PgStat_MsgFuncstat msg_funcstat;
PgStat_MsgFuncpurge msg_funcpurge;
PgStat_MsgRecoveryConflict msg_recoveryconflict;
+ PgStat_MsgDeadlock msg_deadlock;
} PgStat_Msg;
@@ -496,7 +509,7 @@ typedef union PgStat_Msg
* ------------------------------------------------------------
*/
-#define PGSTAT_FILE_FORMAT_ID 0x01A5BC99
+#define PGSTAT_FILE_FORMAT_ID 0x01A5BC9A
/* ----------
* PgStat_StatDBEntry The collector's data per database
@@ -522,6 +535,7 @@ typedef struct PgStat_StatDBEntry
PgStat_Counter n_conflict_startup_deadlock;
PgStat_Counter n_temp_files;
PgStat_Counter n_temp_bytes;
+ PgStat_Counter n_deadlocks;
TimestampTz stat_reset_timestamp;
@@ -746,6 +760,7 @@ extern void pgstat_report_analyze(Relation rel,
PgStat_Counter livetuples, PgStat_Counter deadtuples);
extern void pgstat_report_recovery_conflict(int reason);
+extern void pgstat_report_deadlock(void);
extern void pgstat_initialize(void);
extern void pgstat_bestart(void);