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

*: add last ru consumption for tidb_last_query_info #49769

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

nolouch
Copy link
Member

@nolouch nolouch commented Dec 25, 2023

What problem does this PR solve?

Issue Number: ref #49318

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    with debug version (last query)
    image

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 25, 2023
Signed-off-by: nolouch <nolouch@gmail.com>
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

Merging #49769 (0db4bcc) into master (b719406) will increase coverage by 0.0735%.
Report is 76 commits behind head on master.
The diff coverage is 89.2857%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49769        +/-   ##
================================================
+ Coverage   70.9391%   71.0126%   +0.0735%     
================================================
  Files          1368       1433        +65     
  Lines        396705     426472     +29767     
================================================
+ Hits         281419     302849     +21430     
- Misses        95593     104616      +9023     
+ Partials      19693      19007       -686     
Flag Coverage Δ
integration 43.9306% <89.2857%> (?)
unit 70.9380% <ø> (-0.0011%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 45.9680% <ø> (-6.9352%) ⬇️

@nolouch
Copy link
Member Author

nolouch commented Dec 25, 2023

/retest-required

2 similar comments
@nolouch
Copy link
Member Author

nolouch commented Dec 25, 2023

/retest-required

@nolouch
Copy link
Member Author

nolouch commented Dec 25, 2023

/retest-required

pkg/sessionctx/variable/session.go Outdated Show resolved Hide resolved
@@ -2351,23 +2351,6 @@ func runStmt(ctx context.Context, se *session, s sqlexec.Statement) (rs sqlexec.

sessVars := se.sessionVars

// Record diagnostic information for DML statements
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a behavior change. Before this PR, LastQueryInfo is record even if this function returns error, but after this change, if runStmt returns error and the returned RecordSet is nil, FinishExecuteStmt won't be called so LastQueryInfo won't be recorded either.

Copy link
Member Author

@nolouch nolouch Dec 26, 2023

Choose a reason for hiding this comment

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

Most errors occur during the execution stage, before it records the error of the compile+optimize stage. I think it's reasonable move to here. and you can see the manual test on the issue text. I kill the pd, it can record pd timeout error during execution.

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @djshow832 is it ok to move to FinishExecuteStmt?

Signed-off-by: nolouch <nolouch@gmail.com>
lastRUConsumption = float64(len(sessVars.StmtCtx.OriginalSQL))
})
// Keep the previous queryInfo for `show session_states` because the statement needs to encode it.
sessVars.LastQueryInfo = sessionstates.QueryInfo{
Copy link
Contributor

@glorv glorv Jan 2, 2024

Choose a reason for hiding this comment

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

Another question: is it better that when the statement type is not exec or dml, the lastQueryInfo/LastRUConsumption should be reset instead of just keep unchanged?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can keep unchanged.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 2, 2024
Copy link

ti-chi-bot bot commented Jan 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CabinfeverB, glorv

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2024
Copy link

ti-chi-bot bot commented Jan 3, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-02 08:08:15.960212819 +0000 UTC m=+2157986.997439746: ☑️ agreed by glorv.
  • 2024-01-03 04:26:47.408288166 +0000 UTC m=+2231098.445515092: ☑️ agreed by CabinfeverB.

@ti-chi-bot ti-chi-bot bot merged commit 33480e8 into pingcap:master Jan 3, 2024
18 checks passed
@nolouch nolouch deleted the add-last branch January 3, 2024 06:16
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Feb 18, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #51120.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. labels Apr 18, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #52702.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants