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

[YSQL][ASH] Nested statements should be tracked only if pg_stat_statements tracks them #21031

Closed
1 task done
abhinab-yb opened this issue Feb 12, 2024 · 0 comments
Closed
1 task done
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@abhinab-yb
Copy link
Contributor

abhinab-yb commented Feb 12, 2024

Jira Link: DB-10002

Description

ASH assigns a query id to each statement, it doesn't check if it's a nested statement or not. It can cause discrepancy when that same query id is not in pg_stat_statements.

If pg_stat_statements is only tracking the top level query, and not the nested statements, then the nested statement's samples might be ignored when joined based on query id.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@abhinab-yb abhinab-yb added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Feb 12, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Feb 12, 2024
@hbhanawat hbhanawat removed the status/awaiting-triage Issue awaiting triage label Feb 27, 2024
abhinab-yb added a commit that referenced this issue May 22, 2024
…ements is tracking it

Summary:
ASH's query id is the same as the one present in the pg_stat_statements view. In case of
nested queries, pg_stat_statements may or may not track them, depending on the guc
`pg_stat_statements.track`. This diff tracks the nested query ids with ASH only if
pg_stat_statements is also doing it.

This diff also avoids setting the query id in the post_parse_analyze hook, because in some
cases of nested queries, only the post_parse_analyze hook is called and no subsequent
ExecutorEnd / ProcessUtility hook is called, in which case we would push the query id to the
stack but never pop it. Now, we start tracking the query id at the start of ExecutorStart /
ProcessUtility hook and stop tracking it at the end of ExecutorEnd / ProcessUtility hook or
if there is some error encountered in between.
Jira: DB-10002, DB-11281

Test Plan: ./yb_build.sh --java-test TestYbAsh#testNestedQueriesWithAsh

Reviewers: jason

Reviewed By: jason

Subscribers: hbhanawat, yql, amitanand

Differential Revision: https://phorge.dev.yugabyte.com/D34773
svarnau pushed a commit that referenced this issue May 25, 2024
…ements is tracking it

Summary:
ASH's query id is the same as the one present in the pg_stat_statements view. In case of
nested queries, pg_stat_statements may or may not track them, depending on the guc
`pg_stat_statements.track`. This diff tracks the nested query ids with ASH only if
pg_stat_statements is also doing it.

This diff also avoids setting the query id in the post_parse_analyze hook, because in some
cases of nested queries, only the post_parse_analyze hook is called and no subsequent
ExecutorEnd / ProcessUtility hook is called, in which case we would push the query id to the
stack but never pop it. Now, we start tracking the query id at the start of ExecutorStart /
ProcessUtility hook and stop tracking it at the end of ExecutorEnd / ProcessUtility hook or
if there is some error encountered in between.
Jira: DB-10002, DB-11281

Test Plan: ./yb_build.sh --java-test TestYbAsh#testNestedQueriesWithAsh

Reviewers: jason

Reviewed By: jason

Subscribers: hbhanawat, yql, amitanand

Differential Revision: https://phorge.dev.yugabyte.com/D34773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

3 participants