-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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, store: Plumb the query max execution time to timebox the PD GetRegion grpc calls #56923
executor, store: Plumb the query max execution time to timebox the PD GetRegion grpc calls #56923
Conversation
Hi @HaoW30. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 kubernetes/test-infra repository. |
Hi @HaoW30. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. 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 kubernetes-sigs/prow repository. |
@lhy1024: adding LGTM is restricted to approvers and reviewers in OWNERS files. 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 kubernetes/test-infra repository. |
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
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bb7133, lhy1024, windtalker The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
pkg/executor/batch_point_get.go
Outdated
@@ -235,6 +236,10 @@ func (e *BatchPointGetExec) initialize(ctx context.Context) error { | |||
var indexKeys []kv.Key | |||
var err error | |||
batchGetter := e.batchGetter | |||
if e.Ctx().GetSessionVars().MaxExecutionTime > 0 { | |||
// If MaxExecutionTime is set, we need to set the context deadline for the batch get. | |||
ctx, _ = context.WithTimeout(ctx, time.Duration(e.Ctx().GetSessionVars().MaxExecutionTime)*time.Millisecond) |
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 is safer to to use
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
to follow the best practise and avoid unexpected resource usage risks.
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.
yes, will do to avoid context leakage
@@ -341,6 +341,7 @@ func (builder *RequestBuilder) SetFromSessionVars(dctx *distsqlctx.DistSQLContex | |||
builder.Request.StoreBusyThreshold = dctx.LoadBasedReplicaReadThreshold | |||
builder.Request.RunawayChecker = dctx.RunawayChecker | |||
builder.Request.TiKVClientReadTimeout = dctx.TiKVClientReadTimeout | |||
builder.Request.MaxExecutionTime = dctx.MaxExecutionTime |
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.
IMO adding a timeout to the context should be the final step. If we design with the expectation that the entire execution path checks for ctx.Done
messages, perhaps we should review and document in the gitHub issue which tidb paths lack ctx.Done
checks and list related TODO sub-tasks.
/cc @bb7133
pkg/executor/point_get.go
Outdated
return e.snapshot.Get(ctx, key) | ||
if e.Ctx().GetSessionVars().MaxExecutionTime > 0 { | ||
// if the query has max execution time set, we need to set the context deadline for the get request | ||
ctxWithTimeout, _ := context.WithTimeout(ctx, time.Duration(e.Ctx().GetSessionVars().MaxExecutionTime)*time.Millisecond) |
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.
Ditto.
/ok-to-test |
e117b01
to
ea29ba9
Compare
* Add defer cancel to avoid memory leakage * Fix test context.TestContextDetach (pkg/distsql/context/context_test.go) * update bazel file
b5d8c33
to
8c021ab
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56923 +/- ##
================================================
+ Coverage 72.8166% 73.4422% +0.6256%
================================================
Files 1676 1676
Lines 463603 463669 +66
================================================
+ Hits 337580 340529 +2949
+ Misses 105179 102371 -2808
+ Partials 20844 20769 -75
Flags with carried forward coverage won't be shown. Click here to find out more.
|
What problem does this PR solve?
This change plumbs the TiDB query max execution time to the executor point_get(bath_point_get) and coprocessor(batch_coprocessor) tasks to timebox the GetRegion PD grpc calls (and other task operations).
Issue Number: ref #56753
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.