Skip to content

PG-592 Treat queries with different parent queries as separate entries#403

Merged
artemgavrilov merged 9 commits intopercona:mainfrom
dutow:pg592
Aug 6, 2024
Merged

PG-592 Treat queries with different parent queries as separate entries#403
artemgavrilov merged 9 commits intopercona:mainfrom
dutow:pg592

Conversation

@dutow
Copy link
Copy Markdown
Contributor

@dutow dutow commented Jun 29, 2023

PG-592

  1. Previously pg_stat_monitor had a topquery and topqueryid field, but it was only a sample: it showed one of the top queries executing the specific query.

With this change, the same entry executed by two different functions will result in two entries in the statistics table.

  1. This also fixes a bug where the content of these field disappeared for every second query executed: previously the update function changed topqueryid to 0 if it was non zero, and changed it to the proper id when it was 0. This resulted in an alternating behavior, where for every second executed query the top query disappeared.

After these changes, the top query is always shown.

  1. The previous implementation also leaked dsa memory used to store the parent queries. This is now also fixed.

1. Previously pg_stat_monitor had a `topquery` and `topqueryid` field, but it was only a sample:
it showed one of the top queries executing the specific query.

With this change, the same entry executed by two different functions will result in two entries in the statistics table.

2. This also fixes a bug where the content of these field disappeared for every second query executed:
previously the update function changed topqueryid to `0` if it was non zero, and changed it to the proper id when it was 0.
This resulted in an alternating behavior, where for every second executed query the top query disappeared.

After these changes, the top query is always shown.

3. The previous implementation also leaked dsa memory used to store the parent queries. This is now also fixed.
@it-percona-cla
Copy link
Copy Markdown

it-percona-cla commented Jun 29, 2023

CLA assistant check
All committers have signed the CLA.

* dsa_free changed to assert as it can never happen
* restructured the ifs to be cleaner
  Note: kept the two-level ifs, as that makes more sense with the assert
  Note: didn't convert nested_level checks to macro, as it is used differently at different parts of the code
@dutow dutow requested review from codeforall and hqakhtar July 6, 2023 09:52
Copy link
Copy Markdown
Contributor

@hqakhtar hqakhtar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@codeforall codeforall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@artemgavrilov artemgavrilov self-assigned this Jul 16, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.87%. Comparing base (d7999f1) to head (bf208ea).

Files Patch % Lines
pg_stat_monitor.c 84.61% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
- Coverage   84.99%   84.87%   -0.12%     
==========================================
  Files           3        3              
  Lines        1293     1296       +3     
  Branches      197      198       +1     
==========================================
+ Hits         1099     1100       +1     
  Misses         98       98              
- Partials       96       98       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@darkfronza darkfronza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@Naeem-Akhter Naeem-Akhter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@artemgavrilov artemgavrilov merged commit 130d6b5 into percona:main Aug 6, 2024
@artemgavrilov artemgavrilov changed the title PG-592: Treat queries with different parent queries as separate entries PG-592 Treat queries with different parent queries as separate entries Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants