Repository navigation
MOS-30: Fix graceful shutdown deadlock and timeout - #13
Merged
Merged
Conversation
Shutdown never completed cleanly: - it held clientsMu while calling client.Close, which takes clientsMu again to unregister the client, so one connected client deadlocked it - Start counted itself in the wait group that Shutdown waits on, so shutdown always ran into ShutdownTimeout and reported a timeout - main returned right after cancelling, cutting client connections Close clients after releasing the lock, track only the accept loop and client goroutines in the wait group, exit the accept loop on a closed listener, make Shutdown idempotent, and have main wait for the server to stop (bounded by ShutdownTimeout) before flushing Sentry. Add regression tests for shutdown with 0, 1 and 3 clients and for a repeated Shutdown call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shutdown never completed cleanly:
Close clients after releasing the lock, track only the accept loop and client goroutines in the wait group, exit the accept loop on a closed listener, make Shutdown idempotent, and have main wait for the server to stop (bounded by ShutdownTimeout) before flushing Sentry.
Add regression tests for shutdown with 0, 1 and 3 clients and for a repeated Shutdown call.