Fix reconnect goroutine leaks + only log errors after 30s of failed reconnects#27
Open
dselans wants to merge 1 commit into
Open
Fix reconnect goroutine leaks + only log errors after 30s of failed reconnects#27dselans wants to merge 1 commit into
dselans wants to merge 1 commit into
Conversation
- Publish() no longer leaks a goroutine per failed publish (unbuffered chanErr/chanDone + missing return) - writeError() no longer spawns a goroutine that blocks forever when errChan is unbuffered/full - reconnect() closes the old connection (if alive) so repeated reconnects do not leak amqp connections/goroutines - Reconnect failures log at warn level and only escalate to error after ReconnectErrorAfterSec (default 30s) - avoids alerting on routine server maintenance restarts - Channel setup failure after reconnect retries instead of panicking - Disconnects (nil acknowledger) are no longer written to errChan - DefaultRetryReconnectSec lowered 60s -> 5s - Watcher exits on shutdown instead of reconnecting a closed client
blinktag
approved these changes
Jul 7, 2026
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.
Weekly AMQ maintenance reboots currently cause every consumer to spam errChan (which services log as errors) and leak goroutines. This PR fixes the reconnect path:
Tests: updated nil-ack spec for new behavior, added regression specs for both leaks, old-conn cleanup, and warn-then-error escalation (verified the publish leak spec fails against the old code).