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

planner: recalculate as-of ts of staleread when plan is cached #43204

Merged
merged 2 commits into from
Apr 20, 2023

Conversation

you06
Copy link
Contributor

@you06 you06 commented Apr 19, 2023

What problem does this PR solve?

Issue Number: close #43044

Problem Summary:

What is changed and how it works?

Recalculate the snapshot ts for staleread when it's provided by as of statement.

Check List

Tests

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

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix the bug that prepared staleread cannot read following changes.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 19, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • qw4990

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 19, 2023
@you06
Copy link
Contributor Author

you06 commented Apr 19, 2023

/retest

@@ -179,7 +182,7 @@ func (p *staleReadProcessor) OnSelectTable(tn *ast.TableName) error {
}
return nil
}
return p.evaluateFromStmtTSOrSysVariable(stmtAsOfTS)
return p.evaluateFromStmtTSOrSysVariable(stmtAsOfTS, evaluateTS)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between OnExecutePreparedStmt and OnSelectTable, why do we need to calculate the TS in two places? Is it possible to merge them into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we set the ts evaluator which needs to be calculated to staleness processor when preparing, and it'll be returned and set to plan cache.

When invoking OnExecutePreparedStmt, it only uses the ts evaluator from plan cache, so it's not necessary to set a evaluator that requires calculation to get a timestamp.

@@ -201,7 +204,7 @@ func (p *staleReadProcessor) OnExecutePreparedStmt(preparedTSEvaluator Staleness
return err
}
}
return p.evaluateFromStmtTSOrSysVariable(stmtTS)
return p.evaluateFromStmtTSOrSysVariable(stmtTS, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add some comments about the above logic.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 20, 2023
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Apr 20, 2023
Signed-off-by: you06 <you1474600@gmail.com>

lint

Signed-off-by: you06 <you1474600@gmail.com>

add more test cases

Signed-off-by: you06 <you1474600@gmail.com>

add comment

Signed-off-by: you06 <you1474600@gmail.com>

add comment

Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
@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 Apr 20, 2023
@qw4990
Copy link
Contributor

qw4990 commented Apr 20, 2023

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 12458ad

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 20, 2023
@ti-chi-bot ti-chi-bot merged commit dc3f1e3 into pingcap:master Apr 20, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #43257.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #43550.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 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.

prepare stmt with stale read get wrong result
4 participants