-
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
store/tikv: coprocess streaming tiny fix #6186
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0e1d1b6
[DNM] enable coprocess streaming for integrated testing
tiancaiamao 0b4bad8
check range based on last response
tiancaiamao 05cde22
handle the first response meet lock
tiancaiamao 8a0bbd3
executor,store: make leak test more stable
tiancaiamao e67c48c
Merge branch 'test-leak' into testing
tiancaiamao 5a594f9
Merge branch 'master' into testing
tiancaiamao 47e0ed5
disable
tiancaiamao 76813d8
Merge branch 'master' into testing
tiancaiamao 6bac9eb
address comment
tiancaiamao 877a944
address comment
tiancaiamao 0f4cf65
address comment
tiancaiamao 79f1c37
simplify code and test
tiancaiamao 93448ba
Merge branch 'master' into testing
tiancaiamao d5eb49e
all-test-passed
tiancaiamao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -612,15 +612,19 @@ func (it *copIterator) handleTaskOnce(bo *Backoffer, task *copTask, ch chan copR | |
} | ||
|
||
// Handles the response for non-streaming copTask. | ||
return it.handleCopResponse(bo, resp.Cop, task, ch) | ||
return it.handleCopResponse(bo, resp.Cop, task, ch, resp.Cop) | ||
} | ||
|
||
func (it *copIterator) handleCopStreamResult(bo *Backoffer, stream *tikvrpc.CopStreamResponse, task *copTask, ch chan copResponse) ([]*copTask, error) { | ||
defer stream.Close() | ||
var resp, lastResp *coprocessor.Response | ||
resp = stream.Response | ||
if resp == nil { | ||
// streaming request returns io.EOF, so the first Response is nil. | ||
return nil, nil | ||
} | ||
for { | ||
remainedTasks, err := it.handleCopResponse(bo, resp, task, ch) | ||
remainedTasks, err := it.handleCopResponse(bo, resp, task, ch, lastResp) | ||
if err != nil || len(remainedTasks) != 0 { | ||
return remainedTasks, errors.Trace(err) | ||
} | ||
|
@@ -652,7 +656,9 @@ func (it *copIterator) handleCopStreamResult(bo *Backoffer, stream *tikvrpc.CopS | |
|
||
// handleCopResponse checks coprocessor Response for region split and lock, | ||
// returns more tasks when that happens, or handles the response if no error. | ||
func (it *copIterator) handleCopResponse(bo *Backoffer, resp *coprocessor.Response, task *copTask, ch chan copResponse) ([]*copTask, error) { | ||
// if we're handling streaming coprocessor response, lastResp is the last successful response, | ||
// if we're handling normal request, lastResp and resp is the same. | ||
func (it *copIterator) handleCopResponse(bo *Backoffer, resp *coprocessor.Response, task *copTask, ch chan copResponse, lastResp *coprocessor.Response) ([]*copTask, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using |
||
if regionErr := resp.GetRegionError(); regionErr != nil { | ||
if err := bo.Backoff(BoRegionMiss, errors.New(regionErr.String())); err != nil { | ||
return nil, errors.Trace(err) | ||
|
@@ -672,7 +678,7 @@ func (it *copIterator) handleCopResponse(bo *Backoffer, resp *coprocessor.Respon | |
return nil, errors.Trace(err) | ||
} | ||
} | ||
return buildCopTasksFromRemain(bo, it.store.regionCache, resp, task, it.req.Desc, it.req.Streaming) | ||
return buildCopTasksFromRemain(bo, it.store.regionCache, lastResp, task, it.req.Desc, it.req.Streaming) | ||
} | ||
if otherErr := resp.GetOtherError(); otherErr != "" { | ||
err := errors.Errorf("other error: %s", otherErr) | ||
|
@@ -692,7 +698,7 @@ func (it *copIterator) handleCopResponse(bo *Backoffer, resp *coprocessor.Respon | |
|
||
func buildCopTasksFromRemain(bo *Backoffer, cache *RegionCache, resp *coprocessor.Response, task *copTask, desc bool, streaming bool) ([]*copTask, error) { | ||
remainedRanges := task.ranges | ||
if streaming { | ||
if streaming && resp != nil { | ||
remainedRanges = calculateRemain(task.ranges, resp.Range, desc) | ||
} | ||
return buildCopTasks(bo, cache, remainedRanges, desc, streaming) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add the comment for
lastResp
?