Repository navigation
Fix race in health state - #10781
Fix race in health state#10781
Conversation
The DrainHandlerFunc creates a channel on-demand when it is called, but this can theoretically occur _after_ a drain has completed, in which case the channel is never closed (drainFinished checks nil), so drain will never return. This commit introduces a constructor for State so we can ensure drainCh is always set on creation, avoiding the on-demand channel creation.
Codecov Report
@@ Coverage Diff @@
## master #10781 +/- ##
==========================================
- Coverage 88.06% 88.05% -0.01%
==========================================
Files 188 188
Lines 9062 9060 -2
==========================================
- Hits 7980 7978 -2
Misses 829 829
Partials 253 253
Continue to review full report at Codecov.
|
markusthoemmes
left a comment
There was a problem hiding this comment.
I'm trying to figure out why we did this lazily 😂. Is there a version in the history where we reset and reused the state maybe?
/assign @mattmoor
Maybe you recall?
Looks sound from today's perspective though.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: julz, markusthoemmes The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm I don't recall anything intentional. We should consider coalescing this with the Drainer in |
|
looks like it went in in #3347, and there was no obvious reason it couldn't be in constructor,. I guess we were trying to make zero-value work maybe 🤷 |
The
DrainHandlerFunccreates a channel on-demand when it is called, but this can theoretically occur after a drain has completed, in which case the channel will never be closed (drainFinished()just exits ifdrainChis nil..), and drain will never return.(This is super unlikely to occur in practice since drain takes some time to complete by which time we've ~always called
DrainHandlerFunc, but worth fixing in case we ever make draining quicker!).Release Note
/assign @markusthoemmes @vagababov