mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 05:56:21 +00:00
PG-286: Fix query buffer overflow management.
If pgsm_overflow_target is ON (default, 1) and the query buffer overflows, we now dump the buffer and keep track of how many times pg_stat_monitor changed bucket since that. If an overflow happen again before pg_stat_monitor cycle through pgsm_max_buckets buckets (default 10), then we don't dump the buffer again, but instead report an error, this ensures that only one dump file of size pgsm_query_shared_buffer will be in disk at any time, avoiding slowing down queries to the pg_stat_monitor view. As soon as pg_stat_monitor cycles through all buckets, we remove the dump file and reset the counter (pgss->n_bucket_cycles).
This commit is contained in:
committed by
Hamid Akhtar
parent
df89c3f4a3
commit
8c61e24f95
@@ -306,6 +306,21 @@ typedef struct pgssSharedState
|
||||
pg_atomic_uint64 prev_bucket_usec;
|
||||
uint64 bucket_entry[MAX_BUCKETS];
|
||||
char bucket_start_time[MAX_BUCKETS][60]; /* start time of the bucket */
|
||||
LWLock *errors_lock; /* protects errors hashtable search/modification */
|
||||
/*
|
||||
* These variables are used when pgsm_overflow_target is ON.
|
||||
*
|
||||
* overflow is set to true when the query buffer overflows.
|
||||
*
|
||||
* n_bucket_cycles counts the number of times we changed bucket
|
||||
* since the query buffer overflowed. When it reaches pgsm_max_buckets
|
||||
* we remove the dump file, also reset the counter.
|
||||
*
|
||||
* This allows us to avoid having a large file on disk that would also
|
||||
* slowdown queries to the pg_stat_monitor view.
|
||||
*/
|
||||
bool overflow;
|
||||
size_t n_bucket_cycles;
|
||||
} pgssSharedState;
|
||||
|
||||
#define ResetSharedState(x) \
|
||||
|
||||
Reference in New Issue
Block a user