Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dutow
Copy link
Collaborator

@dutow dutow commented Jun 29, 2023

  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

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
pg_stat_monitor.c Outdated Show resolved Hide resolved
pg_stat_monitor.c Outdated Show resolved Hide resolved
pg_stat_monitor.c Outdated Show resolved Hide resolved
pg_stat_monitor.c Outdated Show resolved Hide resolved
@dutow dutow requested review from hqakhtar and codeforall July 6, 2023 09:52
Copy link
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
Collaborator

@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

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.

None yet

4 participants