-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 the race condition between goroutine and channel on the same leases to be revoked #14067
Conversation
Codecov Report
@@ Coverage Diff @@
## main #14067 +/- ##
==========================================
- Coverage 75.11% 74.96% -0.15%
==========================================
Files 451 451
Lines 36791 36793 +2
==========================================
- Hits 27636 27583 -53
- Misses 7420 7463 +43
- Partials 1735 1747 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Great find! Did you find it yourself or used static analysis. Would be great if we could scan the codebase for more cases like this.
Still I would prefer if we just stop using anonymous functions. Could you maybe refactor this to call a function?
I just found it during code review on the lease related code. I am investigating how can we refactor lease. I have a bias for action, so submit a PR to fix it immediately when I see the issue. Probably some linter tools can discover such issue, and it's in my to do list. Just moved the code into a separate method, and it looks much better now. |
cc @ptabor |
cc @spzala as well. This is a minor change, and it should be safe. |
Nice finding. Benefits of final variables in Java, |
Neither |
It's a classic mistake in using the Golang channel + goroutine. When a goroutine accesses data in the closure environment, we should make a copy of the data for the goroutine.
See the example in effective_go#channels