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

infoschema: add 3 fields to statement summary table #14096

Merged
merged 6 commits into from
Dec 19, 2019

Conversation

djshow832
Copy link
Contributor

@djshow832 djshow832 commented Dec 17, 2019

What problem does this PR solve?

Add 3 more fields to events_statements_summary_by_digest:

  • SUMMARY_END_TIME: the end time of current summary.
  • SUM_BACKOFF_TIMES: the total backoff times of this kind of SQL.
  • PREV_SAMPLE_TEXT: the previous SQL before current SQL if current SQL is commit.

What is changed and how it works?

  • SUMMARY_END_TIME: the end time will change if refreshInterval changes.
  • PREV_SAMPLE_TEXT: the identifier of each kind of SQL is composed of previous digest and current digest, so it can distinguish different types of transactions.

Check List

Tests

  • Unit test

Code changes

  • Has exported variable/fields change

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release note

  • Add 3 more fields to table events_statements_summary_by_digest:
    SUMMARY_END_TIME: the end time of current summary.
    SUM_BACKOFF_TIMES: the total backoff times of this kind of SQL.
    PREV_SAMPLE_TEXT: the previous SQL before current SQL if current SQL is commit.

@djshow832
Copy link
Contributor Author

/bench

@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

Benchmark Report

Run Sysbench Performance Test on VMs

@@                               Benchmark Diff                               @@
================================================================================
--- tidb: 5940bb2ceb7de833839b09341356ef6b0fe38cb7
+++ tidb: fb4d8dbd48b01a9be297e938cc932d332a61ee5d
tikv: 7f17c967ff9d9d778b2c39432cc5465096187261
pd: 8198108644e65c08d6beb7e28ff54ddade5ec542
================================================================================
oltp_update_non_index:
    * QPS: 9263.07 ± 0.26% (std=17.85) delta: 0.39% (p=0.378)
    * Latency p50: 13.81 ± 0.25% (std=0.03) delta: -0.42%
    * Latency p99: 27.66 ± 0.00% (std=0.00) delta: 0.00%
            
oltp_insert:
    * QPS: 4709.87 ± 0.16% (std=5.40) delta: 0.28% (p=0.682)
    * Latency p50: 27.17 ± 0.16% (std=0.03) delta: -0.27%
    * Latency p99: 46.46 ± 5.92% (std=2.00) delta: -2.16%
            
oltp_read_write:
    * QPS: 16316.36 ± 0.12% (std=12.09) delta: 0.33% (p=0.422)
    * Latency p50: 157.27 ± 0.11% (std=0.10) delta: -0.30%
    * Latency p99: 316.39 ± 2.39% (std=5.34) delta: 1.22%
            
oltp_update_index:
    * QPS: 4245.43 ± 0.33% (std=10.60) delta: -0.31% (p=0.997)
    * Latency p50: 30.15 ± 0.35% (std=0.08) delta: 0.31%
    * Latency p99: 54.84 ± 3.56% (std=1.20) delta: -1.19%
            
oltp_point_select:
    * QPS: 41974.43 ± 0.14% (std=41.55) delta: -0.35% (p=0.709)
    * Latency p50: 3.05 ± 0.22% (std=0.00) delta: 0.22%
    * Latency p99: 9.91 ± 1.82% (std=0.13) delta: 0.00%
            

@djshow832 djshow832 force-pushed the stmt_summary_end_time branch 2 times, most recently from 713e06f to c7a869b Compare December 18, 2019 02:41
@codecov
Copy link

codecov bot commented Dec 18, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2cb5eb6). Click here to learn what that means.
The diff coverage is 83.6363%.

@@             Coverage Diff             @@
##             master     #14096   +/-   ##
===========================================
  Coverage          ?   80.1793%           
===========================================
  Files             ?        483           
  Lines             ?     121535           
  Branches          ?          0           
===========================================
  Hits              ?      97446           
  Misses            ?      16320           
  Partials          ?       7769


// tableEventsStatementsSummaryByDigestHistory contains the column name definitions for table
// events_statements_summary_by_digest_history.
const tableEventsStatementsSummaryByDigestHistory = "CREATE TABLE if not exists events_statements_summary_by_digest_history (" +
"SUMMARY_BEGIN_TIME TIMESTAMP(6) NOT NULL," +
"SUMMARY_END_TIME TIMESTAMP(6) NOT NULL," +
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use a constant format string to save the create table SQL if the digest and the history digest table have the same schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good, done.

key.hash = append(key.hash, hack.Slice(key.digest)...)
key.hash = append(key.hash, hack.Slice(key.schemaName)...)
key.hash = append(key.hash, hack.Slice(key.prevDigest)...)
Copy link
Contributor

Choose a reason for hiding this comment

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

The same SQL statement is executed after different statements, the final digest is different? Is it expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, only when current SQL is commit do we record prevSQL. Otherwise, prevSQL is empty. See adaptor.go.
If all commits are grouped in one record, we can't distinguish different transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

@djshow832 OK, It's a convention of coding and it's better to add some comments to hint the maintainer don't break it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed.

ssElement = ssbd.history.Back().Value.(*stmtSummaryByDigestElement)
c.Assert(ssElement.beginTime, GreaterEqual, now-60)
c.Assert(ssElement.beginTime, LessEqual, now2)
c.Assert(ssElement.endTime-ssElement.beginTime, Equals, int64(60))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add some cases to test the expiration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestSummaryHistory tested expiration.

Copy link
Contributor

@lonng lonng left a comment

Choose a reason for hiding this comment

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

Reset LGTM

@bb7133
Copy link
Member

bb7133 commented Dec 18, 2019

Also, please update the Release Notes in your PR Description: list the name of 3 newly added fields and give a brief explanation on why they're added.

@bb7133 bb7133 added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 19, 2019
@bb7133
Copy link
Member

bb7133 commented Dec 19, 2019

LGTM

@bb7133 bb7133 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 19, 2019
@djshow832
Copy link
Contributor Author

/run-unit-test

@djshow832
Copy link
Contributor Author

/run-all-tests

@djshow832 djshow832 merged commit fcc5dba into pingcap:master Dec 19, 2019
djshow832 added a commit to djshow832/tidb that referenced this pull request Dec 20, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants