-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Keep only the latest value in the health channel #14087
Conversation
@@ -87,12 +87,6 @@ func TestNodeHealth_Concurrency(t *testing.T) { | |||
// Number of goroutines to spawn for both reading and writing | |||
numGoroutines := 6 | |||
|
|||
go func() { |
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.
This is the regression test to show that CheckHealth is non-blocking
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.
LGTM!
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.
nice!
* Increase health tracker channel buffer size * keep only the latest value * Make health test blocking as a regression test for PR #14807 * Fix new race conditions in the MockHealthClient --------- Co-authored-by: Preston Van Loon <preston@pvl.dev>
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
#14033 introduced a subtle race condition. The channel has a buffer size of 1. Previously we unlocked before sending to the channel. This means that if we tried to send a second value, sending to the channel blocked but any other function that required the lock could take it. In the current version this other function will need to wait for the lock. And that's what happened with the REST VC. I don't know how exactly it got to this, but apparently a second value was sent to the channel before reading the first one, which captured the lock. Another function tried to obtain the lock, and reading the first value from the channel depended on this function returning.
To fix this, we introduce a switch statement that always replaces the existing value in the channel with a new one.