Skip to content

*: stale reads compatible with prepare (#25156)#25371

Merged
ti-chi-bot merged 7 commits into
pingcap:release-5.1from
ti-srebot:release-5.1-9189ec66ac47
Jun 15, 2021
Merged

*: stale reads compatible with prepare (#25156)#25371
ti-chi-bot merged 7 commits into
pingcap:release-5.1from
ti-srebot:release-5.1-9189ec66ac47

Conversation

@ti-srebot
Copy link
Copy Markdown
Contributor

@ti-srebot ti-srebot commented Jun 11, 2021

cherry-pick #25156 to release-5.1
You can switch your code base to this Pull Request by using git-extras:

# In tidb repo:
git pr https://github.com/pingcap/tidb/pull/25371

After apply modifications, you can push your change to this PR via:

git push git@github.com:ti-srebot/tidb.git pr/25371:release-5.1-9189ec66ac47

What problem does this PR solve?

Issue Number: close #24932

Problem Summary: Prepare is now compatible with stale reads.

What is changed and how it works?

What's Changed:

snapshotTS != 0 is used to indicate that it is a stale read.

  1. CachedPrepareStmt has a new field SnapshotTS to store the result of preprocessing in PrepareExec.
  2. newExecutorBuilder has a new parameter, snapshotTS. It is passed from session.ExecutePreparedStmt, along cachedPlanExec or CompileExecutePreparedStmt. The one in session comes from CachedPrepareStmt.
  3. Skip infoschema check in IsCachedExecOk and OptimizePreparedPlan, if snapshotTS != 0.
  4. plannercore.Execute plan has a new field SnapshotTS to store the timestamp from CachedPrepareStmt.
  5. executorExec.buildExecute will assign snapshotTS from plannercore.Execute plan to executorBuilder.

1-3 covered the prepared execution directly from session/mysql-protocol, and 4-5 covered the execution from plain SQL.

NEW CHANGES: to support dynamic timestamp like NOW() - INTERVAL 1 SECOND:

  1. CachedPrepareStmt do not store infoschema anymore. You need to recheck infoschema before execute to ensure consistency anyway.
  2. As Of statements evaluation is stored/prepared as a closure to support dynamic re-evaluation. For non-prepare statements, they can use LastSnapshotTS to avoid re-evaluation.

Check List

Tests

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

Release note

  • Support prepare stale reads SQL

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot ti-srebot requested review from a team as code owners June 11, 2021 11:33
@ti-srebot ti-srebot requested review from XuHuaiyu and removed request for a team June 11, 2021 11:33
@ti-srebot
Copy link
Copy Markdown
Contributor Author

/run-all-tests

@ti-srebot ti-srebot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/5.1-cherry-pick labels Jun 11, 2021
@ti-srebot
Copy link
Copy Markdown
Contributor Author

@xhebox you're already a collaborator in bot's repo.

Signed-off-by: xhe <xw897002528@gmail.com>
@xhebox xhebox requested review from Yisaer and nolouch and removed request for a team and XuHuaiyu June 11, 2021 12:17
Signed-off-by: xhe <xw897002528@gmail.com>
@zhouqiang-cl zhouqiang-cl added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 15, 2021
@xhebox
Copy link
Copy Markdown
Contributor

xhebox commented Jun 15, 2021

/run-all-tests

@nolouch
Copy link
Copy Markdown
Member

nolouch commented Jun 15, 2021

/run-integration-common-test

Copy link
Copy Markdown
Member

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot
Copy link
Copy Markdown
Member

@nolouch: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

Details

In response to this:

lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@nolouch nolouch removed sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Jun 15, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 15, 2021
@github-actions github-actions Bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Jun 15, 2021
@Yisaer
Copy link
Copy Markdown
Contributor

Yisaer commented Jun 15, 2021

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

@Yisaer: /merge in this pull request requires 2 approval(s).

Details

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@nolouch
Copy link
Copy Markdown
Member

nolouch commented Jun 15, 2021

@Yisaer needs one more approval.

Copy link
Copy Markdown
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot
Copy link
Copy Markdown
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • nolouch

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 15, 2021
@Yisaer
Copy link
Copy Markdown
Contributor

Yisaer commented Jun 15, 2021

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: e4770f2

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 15, 2021
@xhebox
Copy link
Copy Markdown
Contributor

xhebox commented Jun 15, 2021

/run-check_dev

@xhebox
Copy link
Copy Markdown
Contributor

xhebox commented Jun 15, 2021

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

@ti-srebot: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@nolouch
Copy link
Copy Markdown
Member

nolouch commented Jun 15, 2021

/run-check_dev

1 similar comment
@nolouch
Copy link
Copy Markdown
Member

nolouch commented Jun 15, 2021

/run-check_dev

@ti-chi-bot ti-chi-bot merged commit 270a4b2 into pingcap:release-5.1 Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Cherry pick PR approved by release team. sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/5.1-cherry-pick

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants