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
Contributor

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

sre-bot commented Sep 25, 2019

/run-all-tests

@lysu
Copy link
Contributor

lysu commented Sep 25, 2019

/run-unit-test

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp jackysp added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 25, 2019
@coocood
Copy link
Member

coocood commented Sep 25, 2019

LGTM

@coocood coocood added the status/can-merge Indicates a PR has been approved by a committer. label Sep 25, 2019
@sre-bot
Copy link
Contributor Author

sre-bot commented Sep 25, 2019

/run-all-tests

@sre-bot sre-bot merged commit ca80b7b into pingcap:release-3.0 Sep 25, 2019
@lysu
Copy link
Contributor

lysu commented Nov 6, 2019

/run-cherry-picker

1 similar comment
@lysu
Copy link
Contributor

lysu commented Nov 6, 2019

/run-cherry-picker

@sre-bot
Copy link
Contributor Author

sre-bot commented Nov 6, 2019

cherry pick to release-3.1 failed

@lysu
Copy link
Contributor

lysu commented Nov 7, 2019

/run-cherry-picker

@lysu
Copy link
Contributor

lysu commented Nov 7, 2019

/run-cherry-picker

@lysu
Copy link
Contributor

lysu commented Nov 8, 2019

/run-cherry-picker

3 similar comments
@lysu
Copy link
Contributor

lysu commented Nov 8, 2019

/run-cherry-picker

@lysu
Copy link
Contributor

lysu commented Nov 8, 2019

/run-cherry-picker

@you06
Copy link
Contributor

you06 commented Nov 8, 2019

/run-cherry-picker

@sre-bot
Copy link
Contributor Author

sre-bot commented Nov 8, 2019

cherry pick to release-3.1 in PR #13302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants