Skip to content
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

health: shutdown server to set NOT_SERVING and disallow future updates #2513

Merged
merged 2 commits into from
Dec 10, 2018

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Dec 7, 2018

No description provided.

@@ -110,7 +117,14 @@ func (s *Server) Watch(in *healthpb.HealthCheckRequest, stream healthgrpc.Health
func (s *Server) SetServingStatus(service string, servingStatus healthpb.HealthCheckResponse_ServingStatus) {
s.mu.Lock()
defer s.mu.Unlock()
if s.shutdownEvent.HasFired() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could go above the lock. (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be a race if this is not in the lock

goroutine-1: HasFired()=false
goroutine-2: Fire()
goroutine-2: take lock, set Not_serving, release lock
goroutine-1: take lock, set status (to Serving)

s := NewServer()
s.SetServingStatus(testService, healthpb.HealthCheckResponse_SERVING)

s.mu.Lock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing asynchronous happening, so I don't think this needs a lock. Remove the status local entirely maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dfawley dfawley assigned menghanl and unassigned dfawley Dec 7, 2018
@menghanl menghanl merged commit aad0ede into grpc:master Dec 10, 2018
@menghanl menghanl deleted the health_shutdown branch December 10, 2018 22:18
@dfawley dfawley added the Type: Feature New features or improvements in behavior label Dec 13, 2018
@dfawley dfawley added this to the 1.18 Release milestone Dec 13, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants