-
Notifications
You must be signed in to change notification settings - Fork 827
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
fix race condition #2013
base: v6.0.1-hotfix-rpc-8-branch
Are you sure you want to change the base?
fix race condition #2013
Changes from all commits
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 |
---|---|---|
|
@@ -349,6 +349,8 @@ | |
defer wg.Done() | ||
defer func() { | ||
if r := recover(); r != nil { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
err = fmt.Errorf("unexpected panic caught in GetLogsByFilters worker: %v", r) | ||
} | ||
}() | ||
|
@@ -387,16 +389,16 @@ | |
close(resultsChan) // Close the results channel after workers finish | ||
}() | ||
|
||
// Check err after all work is done | ||
if len(errorsList) > 0 { | ||
err = errors.Join(errorsList...) | ||
} | ||
|
||
// Aggregate results into the final slice | ||
for result := range resultsChan { | ||
res = append(res, result) | ||
} | ||
|
||
// Check err after all work is done | ||
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. This ordering adjustment make sense to me, but I wonder why it would lead to dead lock or stuck issue 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. I think it'd cause the 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. make sense to me |
||
if len(errorsList) > 0 { | ||
err = errors.Join(errorsList...) | ||
} | ||
|
||
// Sorting res in ascending order | ||
sort.Slice(res, func(i, j int) bool { | ||
return res[i].BlockNumber < res[j].BlockNumber | ||
|
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.
Is this being hit at all? I think recover() should never be hit in this logic, and it shouldn't be causing any dead lock issue from my understanding. That being said, adding the lock wouldn't hurt as well