Commit Graph

647 Commits

Author SHA1 Message Date
Ibrar Ahmed
1fcdbcefaf Merge pull request #379 from codeforall/main
PG-542: Performance improvement of pg_stat_monitor.
2023-02-23 01:49:28 +05:00
Muhammad Usama
7b0e603bcf PG-542: Performance improvement of pg_stat_monitor.
Saving the client IP address once per the lifetime of a backend. This avoid
the expensive operation multiple times, and hence improving performance
significantly.
2023-02-23 01:33:23 +05:00
Ibrar Ahmed
7b9711eb7d Merge pull request #378 from EngineeredVirus/main
PG-588: Some queries are not being normalised.
2023-02-23 01:24:31 +05:00
Naeem Akhter
be1b4af180 PG-605: Fix TAP Tests framework crash. (#377) 2023-02-22 23:47:03 +05:00
Hamid Akhtar
de66ef0fce 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>
2023-02-22 19:31:52 +05:00
Naeem Akhter
837bacdf3a PG-571: Update Jobs to run on PR and Push. (#374) 2023-02-09 00:35:51 +05:00
Naeem Akhter
4352d97af0 PG-603: Fix/Update String::Util module in TAP test perl. (#373)
Removed use of String::Util perl module from TAP test cases, and now using
Text::Trim module instead, as that is more stable. Also removed the
Data::Str2Num perl module as it was not needed any more.
2023-02-02 15:41:43 +05:00
Vadim Yalovets
32b1219087 Merge pull request #372 from adivinho/Fix-build-script
Fix build script for PG13
2023-02-01 14:14:38 +02:00
Vadim Yalovets
11b9924b3c Fix build script for PG13 2023-02-01 12:13:09 +02:00
Muhammad Usama
8193e527da PG-587: pg_stat_monitor: Validate the upgrade from 1.x to 2.0 version (#370)
Disallow V1 API to be used with V2.0 lib and remove pg_stat_monitor--1.0.sql
as part of that. A few adjustments to 1.x to 2.0 upgrade script are also
part of the commit
2023-02-01 01:38:02 +05:00
Naeem Akhter
62d2ad6d8e Merge pull request #371 from capri1989/PG-571
PG-571: Update badges in README
2023-01-30 19:21:32 +05:00
Kai Wagner
2ccbe416c2 PG-571: Update badges in README
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
2023-01-30 14:14:07 +01:00
Kai Wagner
9b9e1f6eef Merge pull request #368 from capri1989/PG-602
PG-602: Updated the README and added PG15
2023-01-30 13:38:33 +01:00
Ibrar Ahmed
9382f6de8f Merge pull request #369 from Naeem-Akhter/PG-559-testcase
PG-559: Add a TAP testcase for historgram feature.
2023-01-30 17:27:30 +05:00
Naeem Akhter
6939ea282a PG-559: Add a TAP testcase for historgram feature. 2023-01-30 15:45:11 +05:00
Kai Wagner
347ee6cf19 PG-602: Changed release notes to mention the initial PG15 support
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
2023-01-30 09:17:41 +01:00
Kai Wagner
70decec03c PG-602: Updated the README and added PG15 and increased the copyright year to 2023
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
2023-01-30 08:35:48 +01:00
Ibrar Ahmed
a4e60b97bb Merge pull request #367 from EngineeredVirus/main
PG-601: Histogram ranges are not correct
2023-01-26 14:59:17 +05:00
Hamid Akhtar
3b6fc3846c PG-601: Histogram ranges are not correct
Resolved the issue with histogram outlier buckets. Also updated
the printing of bucket ranges to be in correct set notation with
reference to brackets. The lower bounds of buckets always have an
exclusive range except for the first bucket, and the upper bounds
always have an inclusive value.
( or ) => exclusive
{ or } => inclusive

The entire range is enclosed within the {} brackets.
2023-01-25 20:31:14 +05:00
Hamid Akhtar
3487e70cc6 PG-599: PGSM build failure on PG-11
Resolving the compilation issue caused by ereport statement.
2023-01-25 12:51:57 +05:00
Hamid Akhtar
9327c864d3 PG-586: pg_stat_monitor: CPU and user timing should be captured
for utility statements as well

Setting user and sys time to 0 in case there is a problem getting
rusage details.
2023-01-25 12:50:29 +05:00
Hamid Akhtar
ee18c16149 PG-586: pg_stat_monitor: CPU and user timing should be captured
for utility statements as well

Added the necessary capture of resource usage  in the process
utility function. We are now storing CPU and user timings for a
utility statement.
2023-01-25 12:50:29 +05:00
Muhammad Usama
ac8800a637 PG-597: pg_stat_monitor: Remove rounding off for floating point values (#364)
As an observability tool that serves data to other tools, data must be output without any loss. So rounding off causes data loss and rounding off errors when comparing different columns.

Therefore, it was decided to eliminate rounding off when outputting values. Any consumer of this data should round off data to whatever precision it prefers.

This behaviour is also consistent with pg_stat_statements.
2023-01-24 16:54:13 +05:00
Naeem Akhter
e10c615dfb PG-572: Verify 025_compare_pgss.pl TAP test case.
Updated test case for column name change (rows_retrieved -> rows).
2023-01-24 16:10:45 +05:00
Naeem Akhter
fa0ee037a2 PG-574: Verify 026_shared_blocks.pl TAP test case. (#363)
1) Added the Group by clause to make sure that bucket change doesn't have any
impact on aggregates of queries.
2) Updated column names where required.
3) Updated pgbench parameters to reduce the time taken by test case, around
70-80% decrease in time taken by test case.
2023-01-24 02:23:17 +05:00
Naeem Akhter
80608394a2 PG-572: Verify 025_compare_pgss.pl TAP test case. (#362)
1) Added the Group by clause to make sure that bucket change doesn't have any
impact on aggregates of queries.
2) Updated column names where required.
3) Updated pgbench parameters to reduce the time taken by test case, around
70-80% decrease in time taken by test case.
2023-01-24 02:22:39 +05:00
Naeem Akhter
b559221a39 PG-573: Verify 024_check_timings.pl TAP test case. (#361)
Added the Group by caluse to make sure that bucket change doesn't have any
impact on aggregates of queries. Updated column names where required.
2023-01-24 02:21:04 +05:00
Muhammad Usama
5648b99eee PG-585: pg_stat_monitor: Add code comments to the DSA related funcs.. (#360)
Adding code comments for the DSA related functionality.
2023-01-23 14:36:23 +05:00
Hamid Akhtar
dfd41519cf PG-588: Some queries are not being normalised.
There is no specific test case where I can either reproduce or validate
the fix. Though, one of the suspects is this condition in pgss_store.
Therefore removed, and it requires verification.
2023-01-23 12:39:18 +05:00
Hamid Akhtar
1662e9efa1 PG-562: Histogram Ranges/Buckets are not correct.
Replaced the error on server start with a warning. The functionality
now handles "pgsm_histogram_buckets" as the maximum number of histogram
buckets to be created. On init, pg_stat_monitor calculates the max
number of buckets that can be created within the given min/max time
range. If the number is below the user configuration, it emits a
warning in the log file stating the number of max buckets set.
2023-01-23 12:37:51 +05:00
Hamid Akhtar
209f370cef PG-562: Histogram Ranges/Buckets are not correct.
Added buckets for queries that take less than minimum histogram time
and one for the ones taking more than the max value specified.

Also, in case the buckets end up overlapping, on server start, an
error will be thrown informing the user of this issue and requesting
a rectification.

Refactored the code to consolidate the calculations in a single
function.
2023-01-23 12:37:51 +05:00
Hamid Akhtar
1286427445 PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view. (#352)
* PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view.

The view now carries all the columns as pg_stat_statements. This required fixing
data types of some of the columns, renaming a few, as well inclusion of new
columns to make the view fully compatible with pg_stat_statements.

* PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view.

Updating the upgrade sql file from 1.0 to 2.0 version linked with this issue
changes.

* PG-543: pg_stat_monitor: PostgreSQL's pg_stat_statements compatible view.

Updating datum calls to use UInt64 rather than Int64.
2023-01-19 01:55:20 +05:00
Hamid Akhtar
7dece7cf1d PG-582: blk_read_time and blk_write_time are not being rounded. (#353)
* PG-582: blk_read_time and blk_write_time are not being rounded.

Added the round off within the internal function so that values for
blk_read_time, blk_write_time are rounded off to 4 decimal places.

Additionally, added rounding off for the PG15+ columns of
temp_blk_read_time and temp_blk_write_time.

* PG-582: blk_read_time and blk_write_time are not being rounded.

Added rounding off for four JIT related columns introduced for PG15.
2023-01-18 17:17:23 +05:00
Ibrar Ahmed
492682e44e Merge pull request #356 from codeforall/main
PG-400: pg_stat_monitor: Timezone in msgtime column...
2023-01-18 17:06:40 +05:00
Naeem Akhter
402b73e792 PG-584: Verify and 007_settings_pgsm_query_shared_buffer.pl TAP test (#355)
PG-584: Verify and 007_settings_pgsm_query_shared_buffer.pl TAP test case
2023-01-18 17:01:47 +05:00
Muhammad Usama
a75e47add9 PG-400: pg_stat_monitor: Timezone in msgtime column...
The bucket start time reported by pg_stat_monitor does not match the PG time and
timezone. The fix is to use TimestampTz for recording the bucket start time.
2023-01-18 16:38:23 +05:00
Naeem Akhter
f9ef1455ae PG-581: top_queryid expected output verification and change. 2023-01-18 13:05:00 +05:00
Muhammad Usama
caeb5f5e73 PG-579: Querying pg_stat_monitor crashes the server ... (#351)
pgsm_get_ss() must only be called when pg_stat_monitor.so is loaded.
Fix is to move the pgsm_get_ss() call after checking if the pg_stat_monotor
library is loaded or not.
2023-01-17 15:49:38 +05:00
Muhammad Usama
2c5e12af0a PG-488: pg_stat_monitor: Overflow management. (#342)
* PG-488: pg_stat_monitor: Overflow management.

Reimplement the storage mechanism of buckets (for PG-15 onward) and query texts
using Dynamic shared memory. Since the dynamic shared memory can grow into a
swap area, so we get the overflow out of the box.

As PostgreSQL versions prior to V15 does not support sequence scan on dynamic
shared memory hashes, so older versions has to live with the classic shared
memory hash for storing the buckets.

Another noteworthy change with the new design is: it saves the query pointer
inside the bucket, and eventually, the query text gets evicted with the bucket
recycle.

Finally, the dynamic shared memory hash has a built-in locking mechanism, so we
can revisit the whole locking in pg_stat_monitor has the potential for lots of
performance improvements.

* Fixing tap test reported issues and also disabling dynamic hash for all versions

* Updating the expected out file for top_query test case

Co-authored-by: Hamid Akhtar <hamid.akhtar@percona.com>
2023-01-10 17:54:17 +05:00
Ibrar Ahmed
ff75b23257 Merge pull request #347 from Naeem-Akhter/PG-575-Update
PG-575: Enable installcheck-world on PG 14 & 15.
2023-01-05 17:19:50 +05:00
Naeem Akhter
7e7bcb4559 PG-575: Enable installcheck-world on PG 14 & 15.
As we are using compute_query_id on pg14 onwards for PGSM and it
causes the server installcheck-world to fail (same behaviour with PGSS).
To test installcheck-world on pg14 onwards we need to disable compute_query_id
and run server installcheck-world. But for PGSM regression we will still have
compute_query_id on.
2023-01-04 18:59:10 +05:00
Ibrar Ahmed
14b357e8df Merge pull request #346 from Naeem-Akhter/PG310
PG-310: pg_stat_monitor: Bucket is Done vs still being current/last
2023-01-04 17:24:53 +05:00
Naeem Akhter
653b3be2a0 PG-310: pg_stat_monitor: Bucket is Done vs still being current/last
Added a TAP test case to verify the behavior of the new 'bucket_done' column.
2023-01-04 14:26:36 +05:00
Ibrar Ahmed
51b5a5a8fb Merge pull request #345 from Naeem-Akhter/PG570
PG-570: Fix counters test case.
2023-01-04 09:42:02 +05:00
Naeem Akhter
56f4735ab0 PG-570: Fix counters test case.
Updated the test case and expected outout, and also removed the unneeded output
files.
2023-01-03 18:50:53 +05:00
Ibrar Ahmed
7c989337f1 Merge pull request #344 from EngineeredVirus/main
PG-576 - Segmentation fault caused by pg_stat_monitor unique queryid creation mechanism.
2023-01-03 17:58:14 +05:00
Hamid Akhtar
f170322f38 PG-576 - Segmentation fault caused by pg_stat_monitor unique
queryid creation mechanism.

Resolving the crash identified by regression and reported by Naeem.
This fix resolves the issue with incorrect query length in case of
normalized query when the query length exceeds PGSM_QUERY_MAX_LEN.

Resolving the crash identify by regression and reported by Naeem.
2023-01-03 17:55:44 +05:00
Ibrar Ahmed
b60eece145 Merge pull request #341 from EngineeredVirus/main
PG-545: pg_stat_monitor: Same query text should generate same queryid
2022-12-30 04:51:46 +05:00
Hamid Akhtar
30441b6972 PG-545: pg_stat_monitor: Same query text should generate same queryid
Updating tap test case and upgrade SQL file from version 1.0 to 2.0.
2022-12-29 14:45:17 +05:00
Naeem Akhter
e0cea058ed PG-568: Add GH Workflow for PGDG-15 and PPG-15 packages. (#343) 2022-12-29 02:28:36 +05:00