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

executor: forbid read from stale query result #25954

Merged
merged 7 commits into from
Jul 13, 2021

Conversation

xhebox
Copy link
Contributor

@xhebox xhebox commented Jul 5, 2021

Signed-off-by: xhe [email protected]

What problem does this PR solve?

Refer #25876

Problem Summary: Because the design of planner, select SQL in the view is not preprocess/checked while creating. I mean all the handleTableName are ignored due to inCreateOrDropTable mask.

Stale reads, however, relies on handleTableName to get the needed information. And I did not come up with a solution to only preprocess/check-staleness for the table name in the select part but view name.

The result is that, I can not tell if it is a stale query while executing DDL create view, nor can we tell while executing/optimizing. Not from the preprocess result of the whole SQL. It can be extracted from the as ... part, though.

The check is added in the creation process(DDL) to reduce performance impact. It is added in executor, however, due to cyclic imports between planner and ddl.

Check List

Tests

  • Unit test
  • Integration test

Release note

  • Forbid creating view from stale query

@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 5, 2021
@xhebox xhebox marked this pull request as draft July 5, 2021 06:20
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2021
@xhebox xhebox changed the title planner: forbid read from stale query result executor: forbid read from stale query result Jul 6, 2021
@xhebox xhebox requested review from nolouch and Yisaer July 6, 2021 04:35
@xhebox xhebox marked this pull request as ready for review July 6, 2021 04:35
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 6, 2021
@nolouch nolouch removed the sig/execution SIG execution label Jul 9, 2021
Copy link
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 ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 9, 2021
@ti-chi-bot
Copy link
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.

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 Jul 12, 2021
@xhebox
Copy link
Contributor Author

xhebox commented Jul 13, 2021

@Yisaer Please merge.

@ichn-hu
Copy link
Contributor

ichn-hu commented Jul 13, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 758108e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 13, 2021
@ichn-hu
Copy link
Contributor

ichn-hu commented Jul 13, 2021

@xhebox would you add close #25876 in the PR description?

@ti-chi-bot ti-chi-bot merged commit e04181b into pingcap:master Jul 13, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 13, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #26200

@xhebox
Copy link
Contributor Author

xhebox commented Jul 13, 2021

@ichn-hu The fix is a non-elegant workaround due to limitations of TiDB code base. It is not closed because we wanted to do some improvements later. But it is hard. What do you prefer? Open a new issue that may exist for a long time, or just change the name of the old issue.

@ichn-hu
Copy link
Contributor

ichn-hu commented Jul 14, 2021

@ichn-hu The fix is a non-elegant workaround due to limitations of TiDB code base. It is not closed because we wanted to do some improvements later. But it is hard. What do you prefer? Open a new issue that may exist for a long time, or just change the name of the old issue.

I am okay with either way, but if we change the name of the old issue, please make it a feature request and remove the type/bug label. Our team is currently in bug jail, so we need to do so, sorry for bringing inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.1 sig/execution SIG execution size/S Denotes a PR that changes 10-29 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