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

executor: fix unordered trace events in row format #12314

Merged
merged 2 commits into from
Sep 24, 2019

Conversation

lucklove
Copy link
Member

@lucklove lucklove commented Sep 23, 2019

The trace statement can print out a trace tree, however, in row
format, the tree is unordered, where earlier events may be placed
behind.

Signed-off-by: lucklove [email protected]

What problem does this PR solve?

The trace statement may result unordered events tree, for example:

 MySQL  localhost:4000  SQL > trace format='row' select * from mysql.user limit 1;
+------------------------------------------+-----------------+-----------+
| operation                                | startTS         | duration  |
+------------------------------------------+-----------------+-----------+
| trace                                    | 16:22:29.456361 | 763.741µs |
|   ├─*executor.LimitExec.Next             | 16:22:29.456875 | 226.354µs |
|   │ └─*executor.TableReaderExecutor.Next | 16:22:29.456877 | 209.508µs |
|   ├─*executor.LimitExec.Next             | 16:22:29.457109 | 904ns     |
|   └─session.Execute                      | 16:22:29.456371 | 487.914µs |
|     ├─executor.Compile                   | 16:22:29.456448 | 265.957µs |
|     │ └─session.getTxnFuture             | 16:22:29.456455 | 1.173µs   |
|     ├─session.runStmt                    | 16:22:29.456725 | 101.817µs |
|     │ ├─TableReaderExecutor.Open         | 16:22:29.456750 | 37.667µs  |
|     │ │ └─distsql.Select                 | 16:22:29.456765 | 15.333µs  |
|     │ └─session.CommitTxn                | 16:22:29.456813 | 10.098µs  |
|     │   └─session.doCommitWitRetry       | 16:22:29.456815 | 1.873µs   |
|     └─session.ParseSQL                   | 16:22:29.456377 | 12.654µs  |
+------------------------------------------+-----------------+-----------+

session.ParseSQL is behind session.Compile, it's not correct.

What is changed and how it works?

Sort sub events before appending them into chunk.

Check List

Tests

  • Unit test
  • Manual test
trace select * from mysql.user limit 1;

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix unordered trace events in row format.

@CLAassistant
Copy link

CLAassistant commented Sep 23, 2019

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Sep 23, 2019

Codecov Report

Merging #12314 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master    #12314   +/-   ##
=========================================
  Coverage   81.082%   81.082%           
=========================================
  Files          454       454           
  Lines        99128     99128           
=========================================
  Hits         80375     80375           
  Misses       12953     12953           
  Partials      5800      5800

The trace statement can print out a trace tree, however, in row
format, the tree is unordered, where earlier events may be placed
behind.

Signed-off-by: lucklove <[email protected]>
@lucklove lucklove force-pushed the bugfix/trace-with-row-format-unordered branch from 493a359 to 15803e3 Compare September 23, 2019 09:58
@XuHuaiyu
Copy link
Contributor

PTAL @tiancaiamao

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 23, 2019
@tiancaiamao
Copy link
Contributor

Once upon a time, the result is sorted, until I remove it by mistake. @lucklove
https://github.com/pingcap/tidb/pull/11633/files#diff-249234629b44bb39716865035fc89d8eL94

Copy link
Contributor

@XuHuaiyu XuHuaiyu 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
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu XuHuaiyu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 24, 2019
@zz-jason zz-jason added the status/can-merge Indicates a PR has been approved by a committer. label Sep 24, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 24, 2019

Your auto merge job has been accepted, waiting for 12199, 12292

@sre-bot
Copy link
Contributor

sre-bot commented Sep 24, 2019

/run-all-tests

@sre-bot sre-bot merged commit b53a71f into master Sep 24, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 24, 2019

cherry pick to release-3.0 failed

@zz-jason zz-jason deleted the bugfix/trace-with-row-format-unordered branch September 24, 2019 02:21
@zz-jason
Copy link
Member

@lucklove the bot failed to cherry pick this PR to release 3.0 and 3.1, could you manually in your spare time?

@lucklove
Copy link
Member Author

@zz-jason OK, I'll do it

@sre-bot
Copy link
Contributor

sre-bot commented Sep 24, 2019

cherry pick to release-3.1 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants