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) #13302

Merged
merged 3 commits into from
Nov 8, 2019

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Nov 8, 2019

cherry-pick #12392 to release-3.1


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
Copy link
Contributor Author

sre-bot commented Nov 8, 2019

/run-all-tests

Copy link
Contributor

@crazycs520 crazycs520 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

@zz-jason zz-jason added the status/LGT2 Indicates that a PR has LGTM 2. label Nov 8, 2019
@zz-jason zz-jason merged commit 5dd513f into pingcap:release-3.1 Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants