-
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
*: add context for hook of getting/setting variables #38379
Conversation
[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 submitting an approval review. |
Most of this refractor is generated by Goland. Thanks Goland 😢 ❤️ |
56ddc51
to
0e52f50
Compare
/tests |
0e52f50
to
498c7ae
Compare
498c7ae
to
30c7ff8
Compare
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
I don't have any better idea - - |
30c7ff8
to
7a0a8f9
Compare
/test |
Signed-off-by: YangKeao <[email protected]>
7a0a8f9
to
2c432ea
Compare
/test |
/run-all-tests |
@lcwangchao @bb7133 Could you help me to merge this PR? It will block other PR from getting merged, (as I've modified the source code of enterprise-plugin) |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 2c432ea
|
TiDB MergeCI notify✅ Well Done! New fixed [1] after this pr merged.
|
Signed-off-by: YangKeao [email protected]
What problem does this PR solve?
Issue Number: close #38378
Problem Summary:
The set/get hook of variables should be able to call asynchronous functions, which should be protected by a
context.Context
to be able to kill/timeout...What is changed and how it works?
ctx context.Context
forSetGlobal/GetGlobal
definition.SetGlobal/GetGlobal
, and do this step recursively...context.Background()
directly.context.TODO()
in the middle way are modified to the correct context.I have considered several different approches to not bring in such a big change:
context.Background()
. It will not solve any problem, but leave somecontext.Background()
in some hidden paths.SetGlobalFromHook
andSetGlobalFromHookWithoutContext
, and implement the second withSetGlobalFromHook(context.Background(), ...)
. But I realized thatSetGlobalFromHookWithoutContext(
has no difference withSetGlobalFromHook(context.Background()
, then I prefer to use the argument directly.If you have better idea to pass in the context, without so many changes, please leave comments 😃 . Or you think it's not necessary, and use a newly created context with deadline is good enough, please also tells your opinion under this PR.