Summary:
D36801 / adf3c5464bbfc1bf95e3d2143a782964875d507f updated the way how
query id is being popped from the nested query id stack. There was a
bug in the previous workflow -
- Once a new query id comes, push the current query id to the stack and set the current query id to the new query id.
- When popping, the current query id is checked, if it matches the top of the stack, then we pop it.
However, this is incorrect as we never pushed the current query id to
the stack so when we are trying to pop, we will never get a match of the
query id. This would result in the wait events being tracked by incorrect
query ids if `pg_stat_statements.track="all"` was turned on and user
fired nested queries.
This diff fixes this by also pushing the current query id to the stack.
This also fixes a out of bounds error while accessing `query_id_stack.query_ids`
Jira: DB-12988
Test Plan:
./yb_build.sh --java-test TestYbAsh#testNestedQueriesWithAsh
Manually tested by logging the query id while pushing and popping and made sure they are the same
Reviewers: jason
Reviewed By: jason
Subscribers: yql
Differential Revision: https://phorge.dev.yugabyte.com/D38316