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

*: log each `com_stmt_fetch` separately (#11987) #12392

Merged
merged 3 commits into from Sep 25, 2019

Conversation

@sre-bot
Copy link

commented Sep 25, 2019

cherry-pick #11987 to release-3.0


What problem does this PR solve?

to slow log:

In the current master code, slow log will be wrong value(last fetch time(or new start execute time) - last cmd time)
In 2.1 code, slow log will be incompatible value(last fetch time(or new start execute time) - first com_stmt_execute time)
but mysql record com_stmt_exec and com_stmt_fetch for each request.

this pr will change the behavior as MySQL does, although TiDB and MySQL use very different way to handle cursor:

  • MySQL execute sql and save the result in temp table(memory or myisam), then fetch the tmp table
  • TiDB cache the executor-tree and execute when fetch command came and cache partial result in memory(now TiDB-server node is stateless and doesn't write any data in local disk)

so, you may see mysql stmt_execute is slow but fetch super fast, and TiDB both execute and fetch is slow in log.

What is changed and how it works?

  • add LogParitialSlow to recordset
  • Fix stmt_reset should clean up opened cursor in stmt(but pay attention both libmysql c API and jdbc, close ResultSet shouldn't send stmt_reset in current client impl, but mysql server will handle stmt_reset like this)
  • log InPreapre and HasMoreResult in slow log too(help find question)
  • log Parse_time and Compile_time in slow log(it seems miss those two fields)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to update the tidb-ansible repository

Release note

  • Write release note for bug-fix or new feature.

This change is Reviewable

@sre-bot

This comment has been minimized.

Copy link
Author

commented Sep 25, 2019

/run-all-tests

@lysu

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

/run-unit-test

Copy link
Member

left a comment

LGTM

@jackysp jackysp added the status/LGT1 label Sep 25, 2019
@coocood

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

LGTM

@sre-bot

This comment has been minimized.

Copy link
Author

commented Sep 25, 2019

/run-all-tests

@sre-bot sre-bot merged commit ca80b7b into pingcap:release-3.0 Sep 25, 2019
13 checks passed
13 checks passed
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
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.