mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Track statistics for spilling of changes from ReorderBuffer.
This adds the statistics about transactions spilled to disk from ReorderBuffer. Users can query the pg_stat_replication_slots view to check these stats and call pg_stat_reset_replication_slot to reset the stats of a particular slot. Users can pass NULL in pg_stat_reset_replication_slot to reset stats of all the slots. This commit extends the statistics collector to track this information about slots. Author: Sawada Masahiko and Amit Kapila Reviewed-by: Amit Kapila and Dilip Kumar Discussion: https://postgr.es/m/CA+fd4k5_pPAYRTDrO2PbtTOe0eHQpBvuqmCr8ic39uTNmR49Eg@mail.gmail.com
This commit is contained in:
@ -56,6 +56,7 @@ typedef enum StatMsgType
|
||||
PGSTAT_MTYPE_RESETSHAREDCOUNTER,
|
||||
PGSTAT_MTYPE_RESETSINGLECOUNTER,
|
||||
PGSTAT_MTYPE_RESETSLRUCOUNTER,
|
||||
PGSTAT_MTYPE_RESETREPLSLOTCOUNTER,
|
||||
PGSTAT_MTYPE_AUTOVAC_START,
|
||||
PGSTAT_MTYPE_VACUUM,
|
||||
PGSTAT_MTYPE_ANALYZE,
|
||||
@ -68,7 +69,8 @@ typedef enum StatMsgType
|
||||
PGSTAT_MTYPE_RECOVERYCONFLICT,
|
||||
PGSTAT_MTYPE_TEMPFILE,
|
||||
PGSTAT_MTYPE_DEADLOCK,
|
||||
PGSTAT_MTYPE_CHECKSUMFAILURE
|
||||
PGSTAT_MTYPE_CHECKSUMFAILURE,
|
||||
PGSTAT_MTYPE_REPLSLOT,
|
||||
} StatMsgType;
|
||||
|
||||
/* ----------
|
||||
@ -358,6 +360,18 @@ typedef struct PgStat_MsgResetslrucounter
|
||||
int m_index;
|
||||
} PgStat_MsgResetslrucounter;
|
||||
|
||||
/* ----------
|
||||
* PgStat_MsgResetreplslotcounter Sent by the backend to tell the collector
|
||||
* to reset replication slot counter(s)
|
||||
* ----------
|
||||
*/
|
||||
typedef struct PgStat_MsgResetreplslotcounter
|
||||
{
|
||||
PgStat_MsgHdr m_hdr;
|
||||
char m_slotname[NAMEDATALEN];
|
||||
bool clearall;
|
||||
} PgStat_MsgResetreplslotcounter;
|
||||
|
||||
/* ----------
|
||||
* PgStat_MsgAutovacStart Sent by the autovacuum daemon to signal
|
||||
* that a database is going to be processed
|
||||
@ -465,6 +479,22 @@ typedef struct PgStat_MsgSLRU
|
||||
PgStat_Counter m_truncate;
|
||||
} PgStat_MsgSLRU;
|
||||
|
||||
/* ----------
|
||||
* PgStat_MsgReplSlot Sent by a backend or a wal sender to update replication
|
||||
* slot statistics.
|
||||
* ----------
|
||||
*/
|
||||
typedef struct PgStat_MsgReplSlot
|
||||
{
|
||||
PgStat_MsgHdr m_hdr;
|
||||
char m_slotname[NAMEDATALEN];
|
||||
bool m_drop;
|
||||
PgStat_Counter m_spill_txns;
|
||||
PgStat_Counter m_spill_count;
|
||||
PgStat_Counter m_spill_bytes;
|
||||
} PgStat_MsgReplSlot;
|
||||
|
||||
|
||||
/* ----------
|
||||
* PgStat_MsgRecoveryConflict Sent by the backend upon recovery conflict
|
||||
* ----------
|
||||
@ -603,6 +633,7 @@ typedef union PgStat_Msg
|
||||
PgStat_MsgResetsharedcounter msg_resetsharedcounter;
|
||||
PgStat_MsgResetsinglecounter msg_resetsinglecounter;
|
||||
PgStat_MsgResetslrucounter msg_resetslrucounter;
|
||||
PgStat_MsgResetreplslotcounter msg_resetreplslotcounter;
|
||||
PgStat_MsgAutovacStart msg_autovacuum_start;
|
||||
PgStat_MsgVacuum msg_vacuum;
|
||||
PgStat_MsgAnalyze msg_analyze;
|
||||
@ -616,6 +647,7 @@ typedef union PgStat_Msg
|
||||
PgStat_MsgDeadlock msg_deadlock;
|
||||
PgStat_MsgTempFile msg_tempfile;
|
||||
PgStat_MsgChecksumFailure msg_checksumfailure;
|
||||
PgStat_MsgReplSlot msg_replslot;
|
||||
} PgStat_Msg;
|
||||
|
||||
|
||||
@ -627,7 +659,7 @@ typedef union PgStat_Msg
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define PGSTAT_FILE_FORMAT_ID 0x01A5BC9E
|
||||
#define PGSTAT_FILE_FORMAT_ID 0x01A5BC9F
|
||||
|
||||
/* ----------
|
||||
* PgStat_StatDBEntry The collector's data per database
|
||||
@ -782,6 +814,17 @@ typedef struct PgStat_SLRUStats
|
||||
TimestampTz stat_reset_timestamp;
|
||||
} PgStat_SLRUStats;
|
||||
|
||||
/*
|
||||
* Replication slot statistics kept in the stats collector
|
||||
*/
|
||||
typedef struct PgStat_ReplSlotStats
|
||||
{
|
||||
char slotname[NAMEDATALEN];
|
||||
PgStat_Counter spill_txns;
|
||||
PgStat_Counter spill_count;
|
||||
PgStat_Counter spill_bytes;
|
||||
TimestampTz stat_reset_timestamp;
|
||||
} PgStat_ReplSlotStats;
|
||||
|
||||
/* ----------
|
||||
* Backend states
|
||||
@ -1330,6 +1373,7 @@ extern void pgstat_reset_counters(void);
|
||||
extern void pgstat_reset_shared_counters(const char *);
|
||||
extern void pgstat_reset_single_counter(Oid objectid, PgStat_Single_Reset_Type type);
|
||||
extern void pgstat_reset_slru_counter(const char *);
|
||||
extern void pgstat_reset_replslot_counter(const char *name);
|
||||
|
||||
extern void pgstat_report_autovac(Oid dboid);
|
||||
extern void pgstat_report_vacuum(Oid tableoid, bool shared,
|
||||
@ -1342,6 +1386,9 @@ 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_report_replslot(const char *slotname, int spilltxns, int spillcount,
|
||||
int spillbytes);
|
||||
extern void pgstat_report_replslot_drop(const char *slotname);
|
||||
|
||||
extern void pgstat_initialize(void);
|
||||
extern void pgstat_bestart(void);
|
||||
@ -1508,6 +1555,7 @@ extern PgStat_ArchiverStats *pgstat_fetch_stat_archiver(void);
|
||||
extern PgStat_GlobalStats *pgstat_fetch_global(void);
|
||||
extern PgStat_WalStats *pgstat_fetch_stat_wal(void);
|
||||
extern PgStat_SLRUStats *pgstat_fetch_slru(void);
|
||||
extern PgStat_ReplSlotStats *pgstat_fetch_replslot(int *nslots_p);
|
||||
|
||||
extern void pgstat_count_slru_page_zeroed(int slru_idx);
|
||||
extern void pgstat_count_slru_page_hit(int slru_idx);
|
||||
|
Reference in New Issue
Block a user