Repository navigation
Fix client shutdown deadlock when a message buffer is full - #645
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
cl/998560176
branch
2 times, most recently
from
October 14, 2026 16:42
2d41ab8 to
a858365
Compare
`Client.Stop` hangs if one of the per-priority buffers for messages to the server is full, i.e. holds 100 messages or 20 MiB that the server hasn't acked yet. This is likely on machines that can't reach the server for a while, e.g. offline laptops, because local services keep sending messages. Then the process only exits when a watchdog terminates it ungracefully: after 10s on SIGTERM, and after a minute on a config reload (SIGHUP). After a graceful `Die` request, it hangs indefinitely. `Stop` waits for the `RetryLoop`s to terminate before it starts acking the messages left in the outbox, but a `RetryLoop` at its limit doesn't read its input until some of its pending messages are acked, so it never notices that the input was closed. `Stop` now starts draining the outbox before it closes the inputs of the `RetryLoop`s and keeps draining until `SortLoop` has returned. The new tests fill a buffer to its count or size limit, without a communicator and with one that can't deliver messages, and check that `Stop` returns. Without the fix, it doesn't return within the tests' 10s timeout. PiperOrigin-RevId: 999443649
copybara-service
Bot
force-pushed
the
cl/998560176
branch
from
October 14, 2026 17:05
a858365 to
5e3b97b
Compare
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.
Fix client shutdown deadlock when a message buffer is full
Client.Stophangs if one of the per-priority buffers for messages to theserver is full, i.e. holds 100 messages or 20 MiB that the server hasn't acked
yet. This is likely on machines that can't reach the server for a while, e.g.
offline laptops, because local services keep sending messages. Then the
process only exits when a watchdog terminates it ungracefully: after 10s on
SIGTERM, and after a minute on a config reload (SIGHUP). After a graceful
Dierequest, it hangs indefinitely.Stopwaits for theRetryLoops to terminate before it starts acking themessages left in the outbox, but a
RetryLoopat its limit doesn't read itsinput until some of its pending messages are acked, so it never notices that
the input was closed.
Stopnow starts draining the outbox before it closes the inputs of theRetryLoops and keeps draining untilSortLoophas returned.The new tests fill a buffer to its count or size limit, without a communicator
and with one that can't deliver messages, and check that
Stopreturns.Without the fix, it doesn't return within the tests' 10s timeout.