Commit Graph

625 Commits (ac8800a6377da0303635f32d3175671ae632c5e4)

Author SHA1 Message Date
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
Hamid Akhtar b20eda7066 PG-545: pg_stat_monitor: Same query text should generate same queryid
Regardless of the database or the user, the same query will yield the
same query ID. As part of this, a new column, 'pgsm_query_id', is added.

* pgsm_query_id:
pgsm_query_id has the same data type of int8 as the queryid column. If
the incoming SQL command includes any constants, it internally normalizes
the query to remove those constant values with placeholders. Otherwise,
it uses the query directly to generate the query hash.

Since we no longer depend on the server's parse tree mechanism, we can
generate the same hash for the same query text for all server versions.

Also, it is important to note that the hash being calculated is a database,
schema and user independent. So same query text in different databases
will generate the same hash.

This column is not part of the key; rather, for observability purposes only.

* Regression
SQL test case pgsm_query_id.sql is added to the SQL regression.
2022-12-28 14:24:19 +05:00
Ibrar Ahmed f8866272a2
Merge pull request #340 from Naeem-Akhter/PG563
PG-563: Update TAP testcases and output due to changes by DEV.
2022-12-28 10:03:05 +05:00
Naeem Akhter b154da01da PG-563: Update TAP testcases and output due to changes by DEV.
As part of this PR, also updated regression test cases that are related to
following JIRA issues as well.

PG-354	pg_stat_monitor: Remove pg_stat_monitor_settings view
Now we not using pg_stat_monitor_settings view, due to this change majority of
TAP testcase requried output changes.

PG-558: Create test case to verify the function names and count in PGSM.
Added additional output file for SQL test case.

PG-554:	Remove redundant expected output files from regression.
Removed unnecessary output files in TAP testcases where these were not needed.
2022-12-27 18:14:32 +05:00
Naeem Akhter 56001d683f
Merge pull request #324 from ibrarahmad/PG-312
PG-312: Changing the default value of Histogram GUC.
2022-12-24 22:31:39 +05:00
Naeem Akhter d03fb8f0b7
Merge branch 'main' into PG-312 2022-12-24 22:30:23 +05:00
Ibrar Ahmed 96a1d52f08
Merge pull request #339 from Naeem-Akhter/PG-354
PG-354: Update expected output file for functions test case.
2022-12-23 05:22:38 +05:00
Naeem Akhter 0656d5f22d PG-354: Update expected output file for functions testcase. 2022-12-23 01:00:13 +05:00
Ibrar Ahmed 802774a2a7
PG-488: Revert pg_stat_monitor: Overflow management. (#338)
PG-488: Revert pg_stat_monitor: Overflow management.

This patch does not work for  < PostgreSQL - 15. More work required.
2022-12-22 19:15:14 +05:00
Ibrar Ahmed 7c5ad48276
Merge pull request #334 from EngineeredVirus/main
PG-354: pg_stat_monitor: Remove pg_stat_monitor_settings view
2022-12-21 20:34:00 +05:00
Ibrar Ahmed 8dffa8cc97
Merge pull request #336 from codeforall/main
PG-488: pg_stat_monitor: Overflow management.
2022-12-21 00:42:47 +05:00
Muhammad Usama df0580b741 PG-488: pg_stat_monitor: Overflow management.
Reimplement the storage mechanism of buckets 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.

oreover the new design 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 potential for lots of performance improvements
2022-12-20 17:29:15 +05:00
Naeem Akhter 5a6b824737
PG-373: Update test case - Remove WAL fields for PG12 and below. (#335) 2022-12-14 12:50:29 +05:00
Hamid Akhtar 2917ae6805 PG-354: pg_stat_monitor: Remove pg_stat_monitor_settings view
Removing the view for 2.0. Updating the required SQL files to manage
the upgrade. Downgrade from 2.x to 1.x is not supported.

Also part of this fix is the SQL regression. This does not update the
tap test cases.
2022-12-13 17:05:46 +05:00
Ibrar Ahmed a6099d6a84
Merge pull request #333 from Naeem-Akhter/PG-558
PG-558: Create test case to verify the function names and count in PGSM.
2022-12-13 16:29:52 +05:00
Naeem Akhter 1037fb08a8 PG-558: Create test case to verify the function names and count in PGSM. 2022-12-12 23:11:38 +05:00
Naeem Akhter 5cd4f255d1
Merge pull request #332 from ibrarahmad/PG-373
PG-373: Remove WAL fields for PG12 and below.
2022-12-12 15:17:43 +05:00
Naeem Akhter 2838eaa94d
Merge pull request #331 from ibrarahmad/PGSM-518
PG-518: Internal Functions should NOT be visible in PGSM API.
2022-12-12 15:16:53 +05:00
Ibrar Ahmed 3076d5bf5c PG-373: Remove wal fields for PG12 and below. 2022-12-07 15:03:14 +00:00
Ibrar Ahmed 5ae0f3a0bb PG-518: Internal Functions should NOT be visible in PGSM API. 2022-12-07 14:52:45 +00:00
Muhammad Usama 913064b68d
PG-435: Adding new counters that are available in PG15 (#329)
In line with pg_stat_statments for PG15, This commit adds eight new cumulative
counters for jit operations, making it easier to diagnose how JIT is used in an
installation. And two new columns, temp_blk_read_time, and temp_blk_write_time,
respectively, show the time spent reading and writing temporary file blocks
on disk.
Moreover, The commit also contains a few indentations and API adjustments.
2022-12-07 15:40:13 +05:00
Naeem Akhter 4a254a538b PG-553: Add a testcase to verify columns names in PGSM. 2022-12-01 12:06:08 +05:00
Ibrar Ahmed 354b92b8b6 PG-312: Changing the default value of Histogram GUC. 2022-11-23 14:49:21 +00:00