mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 05:56:21 +00:00
PG-223: Remove relations and num_relations from pgssSharedState.
These variables can't be in shared state, as the following problem was taking place: 1. Process1 call pgss_ExecutorCheckPerms(), acquire lock, update relations and num_relations, release lock. 2. Process 2 call pgss_ExecutorCheckPerms(), acquire lock, update num_relations = 0; 3. Process 1 read num_relations = 0 in pgss_update_entry, this value is wrong as it was updated by Process 2. Even if we acquire the lock in pgss_update_entry to read num_relations and relations variable, Process 1 may end up acquiring the lock after Process 2 has ovewritten the variable values, leading to Process 1 reading of wrong data. By defining relations and num_relations to be static and global in pg_stat_monitor.c we take advantage that each individual PostgreSQL backend will have its own copy of this data, which allows us to remove the locking in pgss_ExecutorCheckPerms to update these variables, improving pg_stat_monitor overall performance.
This commit is contained in:
@@ -310,8 +310,6 @@ typedef struct pgssSharedState
|
||||
uint64 prev_bucket_usec;
|
||||
uint64 bucket_entry[MAX_BUCKETS];
|
||||
int64 query_buf_size_bucket;
|
||||
char relations[REL_LST][REL_LEN];
|
||||
int num_relations; /* Number of relation in the query */
|
||||
char bucket_start_time[MAX_BUCKETS][60]; /* start time of the bucket */
|
||||
} pgssSharedState;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user