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,session: display the tree-like format of the trace statement #11633

Merged
merged 3 commits into from Aug 6, 2019

Conversation

@tiancaiamao
Copy link
Contributor

commented Aug 6, 2019

What problem does this PR solve?

Fix the trace format = 'row' ... output.

Before:

mysql> trace format='row'  select 1, (select sleep(1));
+---------------------------------------+-----------------+--------------+
| operation                             | startTS         | duration     |
+---------------------------------------+-----------------+--------------+
| session.getTxnFuture                  | 13:07:52.726034 | 26.435µs     |
|   ├─session.Execute                   | 13:07:52.726027 | 1.00091883s  |
|   ├─session.ParseSQL                  | 13:07:52.726153 | 87.241µs     |
|   ├─executor.Compile                  | 13:07:52.726311 | 1.00057122s  |
|   ├─executor.EvalSubQuery             | 13:07:52.726621 | 1.000212522s |
|   ├─*executor.MaxOneRowExec.Next      | 13:07:52.726651 | 1.000170599s |
|   ├─*executor.ProjectionExec.Next     | 13:07:52.726657 | 1.000110148s |
|   ├─*executor.TableDualExec.Next      | 13:07:52.726663 | 2.632µs      |
|   ├─*executor.ProjectionExec.Next     | 13:07:53.726801 | 8.778µs      |
|   ├─*executor.TableDualExec.Next      | 13:07:53.726804 | 545ns        |
|   ├─*executor.MaxOneRowExec.Next      | 13:07:53.726829 | 492ns        |
|   ├─session.runStmt                   | 13:07:53.726892 | 25.862µs     |
|   ├─session.CommitTxn                 | 13:07:53.726910 | 3.252µs      |
|   ├─*executor.ProjectionExec.Next     | 13:07:53.726954 | 8.484µs      |
|   ├─*executor.TableDualExec.Next      | 13:07:53.726955 | 458ns        |
|   ├─*executor.ProjectionExec.Next     | 13:07:53.726967 | 4.26µs       |
|   └─*executor.TableDualExec.Next      | 13:07:53.726968 | 327ns        |
+---------------------------------------+-----------------+--------------+
17 rows in set (1.02 sec)

After:

mysql> trace format='row'  select 1, (select sleep(1));
+----------------------------------------------------+-----------------+--------------+
| operation                                          | startTS         | duration     |
+----------------------------------------------------+-----------------+--------------+
| session.Execute                                    | 13:01:01.350899 | 1.001122606s |
|   ├─session.ParseSQL                               | 13:01:01.351012 | 62.718µs     |
|   ├─executor.Compile                               | 13:01:01.351327 | 1.000635173s |
|   │ └─executor.EvalSubQuery                        | 13:01:01.351675 | 1.000236307s |
|   │   ├─*executor.MaxOneRowExec.Next               | 13:01:01.351717 | 1.000183409s |
|   │   │ ├─*executor.ProjectionExec.Next            | 13:01:01.351725 | 1.000117021s |
|   │   │ │ └─*executor.TableDualExec.Next           | 13:01:01.351732 | 3.911µs      |
|   │   │ └─*executor.ProjectionExec.Next            | 13:01:02.351886 | 10.062µs     |
|   │   │   └─*executor.TableDualExec.Next           | 13:01:02.351891 | 606ns        |
|   │   └─*executor.MaxOneRowExec.Next               | 13:01:02.351907 | 578ns        |
|   ├─session.runStmt                                | 13:01:02.351972 | 21.68µs      |
|   │ └─session.CommitTxn                            | 13:01:02.351987 | 2.941µs      |
|   ├─session.getTxnFuture                           | 13:01:01.350914 | 25.686µs     |
|   ├─*executor.ProjectionExec.Next                  | 13:01:02.352029 | 9.203µs      |
|   │ └─*executor.TableDualExec.Next                 | 13:01:02.352030 | 477ns        |
|   └─*executor.ProjectionExec.Next                  | 13:01:02.352045 | 4.33µs       |
|     └─*executor.TableDualExec.Next                 | 13:01:02.352046 | 349ns        |
+----------------------------------------------------+-----------------+--------------+
17 rows in set (1.01 sec)

What is changed and how it works?

  1. Add ctx = opentracing.ContextWithSpan(ctx, span1)
f(ctx) {
   // span for tracing f
   // should create a ctx for g, otherwise, f's parent span and g's parent span is the same one!
   g(ctx)
}
  1. Remove the sort trace result by the start time

The dfsTree print the trace result according to the parent-children relationship, sort by start time is useless.

  1. Remove the trace code in UpdateExec because of the executor.Executor has already added it

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Related changes

  • Need to cherry-pick to the release branch
@tiancaiamao

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2019

@codecov

This comment has been minimized.

Copy link

commented Aug 6, 2019

Codecov Report

Merging #11633 into master will decrease coverage by 0.1167%.
The diff coverage is 77.7777%.

@@               Coverage Diff               @@
##            master     #11633        +/-   ##
===============================================
- Coverage   81.363%   81.2463%   -0.1168%     
===============================================
  Files          426        426                
  Lines        92998      91950      -1048     
===============================================
- Hits         75666      74706       -960     
+ Misses       11926      11880        -46     
+ Partials      5406       5364        -42
@lysu
Copy link
Member

left a comment

LGTM

@jackysp

jackysp approved these changes Aug 6, 2019

Copy link
Member

left a comment

LGTM

@jackysp jackysp closed this Aug 6, 2019

@jackysp jackysp reopened this Aug 6, 2019

@jackysp jackysp merged commit 02ab1ed into pingcap:master Aug 6, 2019

6 checks passed

ci/circleci Your tests passed on CircleCI!
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@sre-bot

This comment has been minimized.

Copy link

commented Aug 6, 2019

cherry pick to release-3.0 failed

@tiancaiamao tiancaiamao deleted the tiancaiamao:trace-tree-format branch Aug 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.