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

remove a race condition in sdk testutil server stop #10342

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (s *TestServer) Stop() error {
return err
case <-time.After(10 * time.Second):
s.cmd.Process.Signal(syscall.SIGABRT)
s.cmd.Wait()
Comment on lines 344 to -345
Copy link
Contributor

@dnephin dnephin Jun 8, 2021

Choose a reason for hiding this comment

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

I think we do still want to wait for the process to exit in this case, because there is a defer at the top of this function which is responsible for removing the temporary directory. We want to make sure the process has exited before we try and remove it to make sure the cleanup succeeds.

I think we can do that by blocking on a read from the waitDone channel instead of calling s.cmd.Wait()

<-waitDone
return ...

Sending SIGABRT should ensure the process exits, so it should be safe to block here in the main goroutine. We might want to change this signal to SIGKILL at some point, if the process is not shutting down with SIGABRT, but I think we can wait to make that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @dnephin that totally makes sense. Can you check the last commit ?

<-waitDone
return fmt.Errorf("timeout waiting for server to stop gracefully")
}
}
Expand Down