Repository navigation
fix(broker): non-blocking inbox send prevents heartbeat timeout under load - #22
Merged
Merged
Conversation
…meout Queue.Publish previously blocked on a full inbox channel (capacity 4096). When called from the connection read loop during sustained high-throughput publishing, this blocked the read loop goroutine, preventing heartbeat frame processing. The heartbeat timeout goroutine would then close the connection, causing publisher disconnects at ~700K messages. Fix: use a non-blocking send on the inbox channel. If the inbox is full, fall back to synchronous PublishSync (write directly to the store under lock). This provides backpressure without stalling the read loop. Verified: 1M messages at 85K msg/s (4P/4C) on 32-core AMD EPYC with no publisher disconnects or consumer stalls.
jamesainslie
force-pushed
the
fix-consumer-stall
branch
from
March 30, 2026 12:12
81ab753 to
7e26bcd
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.
Summary
Fixed a critical bug where publishers disconnected during sustained high-throughput publishing (~700K+ messages).
Root cause:
Queue.Publishblocked on a full inbox channel (capacity 4096) while called from the connection's read loop. This stalled heartbeat frame processing, causing the heartbeat timeout goroutine to close the connection.Fix: Non-blocking send on the inbox channel. If full, falls back to synchronous
PublishSync(writes directly to the store under lock). This provides backpressure without blocking the read loop.Verified on 32-core AMD EPYC-Milan (251GB RAM)
Test plan
-race