-
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
lightning: fix "context cancel" overwrites the real error #44734
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1145,14 +1145,16 @@ func (local *Backend) generateAndSendJob( | |
for _, jobRange := range jobRanges { | ||
r := jobRange | ||
eg.Go(func() error { | ||
select { | ||
case <-egCtx.Done(): | ||
if egCtx.Err() != nil { | ||
return nil | ||
default: | ||
} | ||
|
||
failpoint.Inject("beforeGenerateJob", nil) | ||
jobs, err := local.generateJobForRange(egCtx, engine, r, regionSplitSize, regionSplitKeys) | ||
if err != nil { | ||
if common.IsContextCanceledError(err) { | ||
return nil | ||
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. if we return nil here, caller will continue running 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. it's expected? because context is 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. will this happen:
maybe add ctx.Err into firstErr before return 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. |
||
} | ||
return err | ||
} | ||
for _, job := range jobs { | ||
|
@@ -1189,6 +1191,9 @@ func (local *Backend) generateJobForRange( | |
regionSplitSize, regionSplitKeys int64, | ||
) ([]*regionJob, error) { | ||
failpoint.Inject("fakeRegionJobs", func() { | ||
if ctx.Err() != nil { | ||
failpoint.Return(nil, ctx.Err()) | ||
} | ||
key := [2]string{string(keyRange.start), string(keyRange.end)} | ||
injected := fakeRegionJobs[key] | ||
// overwrite the stage to regionScanned, because some time same keyRange | ||
|
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.
any difference?
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.
select {}
will lock the channel to read the value so performance is better. And code becomes shorter