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

*: consitent get infoschema #24230

Merged
merged 9 commits into from
May 10, 2021
Merged

*: consitent get infoschema #24230

merged 9 commits into from
May 10, 2021

Conversation

xhebox
Copy link
Contributor

@xhebox xhebox commented Apr 23, 2021

What problem does this PR solve?

The main issue: #24233

Problem Summary: In some cases, TxnCtx.InfoSchema is directly used while there may be SnapshotInfoSchema. There was a similar fix #15258, only for distsql. There are more left cases:

executor/coprocessor.go: buildDAGExecutor
executor/infoschema_reader.go: setDataForTiKVRegionStatus, setDataForTiDBHotRegions
expression/builtin_info.go: builtinNextValSig.evalInt, builtinLastValSig.evalInt, builtinSetValSig.evalInt
planner/core/expression_rewriter.go: rewriteAstExpr
planner/core/integration_test.go: TestPartitionPruningForEQ

While I want to replace all TxnCtx.InfoSchema into infoschema.GetInfoSchema(sessionCtx), I found that there will be a circular dependency in expression -> ... -> infoschema -> expression.

So I moved GetInfoSchema function into sessionctx/variable, as a method of SessionVars. Then replaced all calls into sessionVars.GetInfoSchema().(infoschema.InfoSchema). For expression package, it is sessionVars.GetInfoSchema().(util.SequenceSchema). That is why this PR is large.

The call is a bit longer with the extra GetSessionVars() and type cast .(infoschema.InfoSchema), but it works and removed one of four sessionctx imports in the infoschema package. Hopefully infoschema will not depend on sessionctx in the future...

Check List

Tests

  • Unit test
  • Integration test

Release note

  • Fix tidb_snapshot did not take effect in some cases

@xhebox xhebox requested review from a team as code owners April 23, 2021 05:20
@xhebox xhebox requested review from wshwsh12 and time-and-fate and removed request for a team April 23, 2021 05:20
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 23, 2021
@AilinKid
Copy link
Contributor

/run-all-tests

@xhebox
Copy link
Contributor Author

xhebox commented Apr 23, 2021

/run-unit-test

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 24, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2021
@djshow832
Copy link
Contributor

/lgtm

@ti-chi-bot ti-chi-bot added status/LGT1 Indicates that a PR has LGTM 1. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 27, 2021
@xhebox xhebox requested a review from bb7133 May 7, 2021 02:47
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 7, 2021
@bb7133
Copy link
Member

bb7133 commented May 10, 2021

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • djshow832

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.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 May 10, 2021
@bb7133
Copy link
Member

bb7133 commented May 10, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 02152ca

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 10, 2021
@ti-chi-bot
Copy link
Member

/run-all-tests

This bot automatically retries jobs that failed on can merge PRs (send feedback to hi-rustin).

Silence the bot with the /merge cancel comment for consistent failures.

@ti-chi-bot ti-chi-bot merged commit 5e9e0e6 into pingcap:master May 10, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request May 10, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #24528

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request May 10, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #24529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression needs-cherry-pick-release-5.0 sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/L Denotes a PR that changes 100-499 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants