-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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, sessionvar: avoid sending same task id to TiFlash #23747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- different tidb server may also conflict on task id if getting the timestamp at the same time.
- due to killing queries by the query id, i.e. start ts, all queries in a transaction will be cancelled if just killing one of them.
@@ -820,6 +826,18 @@ type SessionVars struct { | |||
AllowFallbackToTiKV map[kv.StoreType]struct{} | |||
} | |||
|
|||
// AllocMPPTaskID allocates task id for mpp tasks. It will reset the task id if the query's | |||
// startTs is different. | |||
func (s *SessionVars) AllocMPPTaskID(startTS uint64) int64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a mutex to avoid write conflicts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's only required by one session. You can notice that every variable in SessionVars is vulnerable.
It's impossible that two transaction shared same timestamp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
@fzhedu: In response to this:
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. |
/lgtm |
/run-sqllogic-test-1 |
/merge |
@hanfei1991: In response to this:
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. |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.0 in PR #23935 |
What problem does this PR solve?
Issue Number: close pingcap/tiflash#1706
For queries in same txn, the task ids sent to TiFlash might be same. I will cause some errors with a very small probability.
What is changed and how it works?
What's Changed:
Like AllocColumnID, we add a AllocMPPTaskID function in SessionVars. If the start_ts varies, the task id will reset.
Check List
Tests
Release note