mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 14:06:20 +00:00
PG-588: Some queries are not being normalised.
This bug uncovered serious issues with how the data was being stored by PSGM. So it require a complete redesign. pg_stat_monitor now stores the data locally within the backend process's local memory. The data is only stored when the query completes. This reduces the number of lock acquisitions that were previously needed during various stages of the execution. Also, this avoids data loss in case the current bucket changes during execution. Also, the unavailability of jumble state during later stages of executions was causing pg_stat_monitor to save non-normalized query. This was a major problem as well. pg_stat_monitor specific memory context is implemented. It is used for saving data locally. The context memory callback helps us clear the locally saved data so that we do not store it multiple times in the shared hash. As part of this major rewrite, pgss reference in function and variable names is changed to pgsm. Memory footprint for the entries is reduced, data types are corrected where needed, and we've removed unused variables, functions and macros. This patch was mutually created by: Co-authored-by: Hamid Akhtar <hamid.akhtar@percona.com> Co-authored-by: Muhammad Usama <muhammad.usama@percona.com>
This commit is contained in:
@@ -10,6 +10,7 @@ DELETE FROM t1;
|
||||
SELECT b FROM t2 FOR UPDATE;
|
||||
TRUNCATE t1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ SELECT * FROM t1,t2 WHERE t1.a = t2.b;
|
||||
SELECT * FROM t3,t4 WHERE t3.c = t4.d;
|
||||
|
||||
\c contrib_regression
|
||||
DROP DATABASE db2;
|
||||
|
||||
SELECT datname, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
@@ -27,11 +29,6 @@ SELECT pg_stat_monitor_reset();
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
\c db2
|
||||
DROP TABLE t3;
|
||||
DROP TABLE t4;
|
||||
|
||||
\c contrib_regression
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
||||
@@ -14,3 +14,4 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
|
||||
SET ROLE su;
|
||||
DROP USER u1;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
DROP USER su;
|
||||
|
||||
@@ -29,6 +29,14 @@ SELECT pg_stat_monitor_reset();
|
||||
SELECT * FROM t1;
|
||||
SELECT *, ADD(1, 2) FROM t1;
|
||||
SELECT * FROM t2;
|
||||
-- Check that spaces and comments do not generate a different pgsm_query_id
|
||||
SELECT * FROM t2 --WHATEVER;
|
||||
;
|
||||
SELECT * FROM t2 /* ...
|
||||
...
|
||||
More comments to check for spaces.
|
||||
*/
|
||||
;
|
||||
|
||||
\c db2
|
||||
SELECT * FROM t1;
|
||||
@@ -36,7 +44,7 @@ SELECT *, ADD(1, 2) FROM t1;
|
||||
SELECT * FROM t3;
|
||||
|
||||
\c contrib_regression
|
||||
SELECT datname, pgsm_query_id, query FROM pg_stat_monitor ORDER BY pgsm_query_id, query, datname;
|
||||
SELECT datname, pgsm_query_id, query, calls FROM pg_stat_monitor ORDER BY pgsm_query_id, query, datname;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
\c db1
|
||||
|
||||
@@ -16,4 +16,5 @@ SELECT query, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
||||
@@ -6,25 +6,37 @@ CREATE EXTENSION pg_stat_monitor;
|
||||
CREATE USER u1;
|
||||
CREATE USER u2;
|
||||
|
||||
SET ROLE su;
|
||||
GRANT ALL ON SCHEMA public TO u1;
|
||||
GRANT ALL ON SCHEMA public TO u2;
|
||||
|
||||
SET ROLE su;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
SET ROLE u1;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
CREATE TABLE t1 (a int);
|
||||
SELECT * FROM t1;
|
||||
|
||||
SET ROLE u2;
|
||||
CREATE TABLE t2 (a int);
|
||||
SELECT * FROM t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
SET ROLE su;
|
||||
SELECT userid, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
DROP OWNED BY u2;
|
||||
DROP USER u2;
|
||||
|
||||
SELECT username, query FROM pg_stat_monitor ORDER BY username, query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP OWNED BY u1;
|
||||
DROP USER u1;
|
||||
DROP USER u2;
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
||||
SET ROLE NONE;
|
||||
|
||||
DROP OWNED BY su;
|
||||
DROP USER su;
|
||||
|
||||
Reference in New Issue
Block a user