-
Notifications
You must be signed in to change notification settings - Fork 253
client: break loop if entry is nil #1837
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: bufferflies <1045931706@qq.com>
7ac4e02 to
5d240ae
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rleungx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughAdds an exhaust flag to the internal batching logic that signals when no additional requests remain available. When the flag is set, the batching loop exits early, modifying the control flow of batch extraction without affecting public interfaces. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✏️ Tip: You can disable this entire section by setting Comment |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/client/client_batch.go (1)
155-193: Bug:exhaustflag can never be set totrue.The assignment
exhaust = len(reqs) == 0on line 182 is placed inside thefor _, e := range reqsloop. This means:
- If
reqsis empty, the loop body never executes, soexhauststaysfalse.- If
reqsis non-empty,len(reqs) > 0inside the loop, soexhaustis set tofalse.The check should occur at the start of the
buildfunction, before entering the loop.🐛 Proposed fix
build := func(reqs []Item) { + if len(reqs) == 0 { + exhaust = true + return + } for _, e := range reqs { e := e.(*batchCommandsEntry) if e.isCanceled() { continue } if e.priority() < highTaskPriority { count++ } if collect != nil { collect(b.idAlloc, e) } if e.forwardedHost == "" { b.requestIDs = append(b.requestIDs, b.idAlloc) b.requests = append(b.requests, e.req) } else { batchReq, ok := b.forwardingReqs[e.forwardedHost] if !ok { batchReq = &tikvpb.BatchCommandsRequest{} b.forwardingReqs[e.forwardedHost] = batchReq } batchReq.RequestIds = append(batchReq.RequestIds, b.idAlloc) batchReq.Requests = append(batchReq.Requests, e.req) } b.idAlloc++ - exhaust = len(reqs) == 0 } }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/client/client_batch.go
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
ref code:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.