Repository navigation
Conversation
In `fnsBroadcaster.Broadcast`, the finality channel was unbuffered and the polling goroutine ran `final <- getFinality(...)`. When `fns.Ordering().Broadcast(...)` failed, the function returned without ever reading `<-final`, so the goroutine blocked forever on its send and leaked permanently. Repeated submit failures accumulated one leaked goroutine each, along with up to 10s of pointless finality polling per leak. Buffer the finality channel so the send can always complete, and derive a cancellable context that is cancelled on return so an orphaned poller stops promptly instead of running out its retry budget with nobody listening. `getFinality` now takes that context, passes it to `IsFinal`, and waits on a `select` over `ctx.Done()` and the retry timer rather than a blind `time.Sleep`; it also skips the trailing sleep after the final attempt. The broadcast logic moves into `broadcastAndWaitForFinality`, behind a small consumer-side `ordering` interface, so it is unit-testable without a full `fabric.NetworkServiceProvider`. The exported `EnvelopeBroadcaster` and `Submitter` interfaces are unchanged, so there is no ripple into callers. Tests cover the `getFinality` retry matrix, early cancellation, and the success and finality-error paths, plus two `goleak` regression tests for the broadcast-error path. Both fail against the previous implementation with goroutines parked in the finality poller. Fixes #2559 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Akram Bitar <akram@il.ibm.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.
Broadcaststarted a finality poller that sent on an unbuffered channel. When the ordering call failed, the function returned without reading it — so the poller blocked forever on its send. One goroutine leaked permanently per failed submit.Fix: buffer the channel so the send always completes, and cancel the poller's context on return so it stops instead of burning its full retry budget unheard.
Also:
getFinalitytakes a context, passes it toIsFinal, and waits onselectoverctx.Done()/timer instead of a blindtime.Sleep. Broadcast logic moved intobroadcastAndWaitForFinalitybehind a smallorderinginterface so it is testable without a real network service. Exported interfaces unchanged.Tests: two
goleakregression tests — both fail against the old code with goroutines parked in the poller — plus the retry matrix and cancellation cases.make checksclean, green under-race.Fixes #2559
🤖 Generated with Claude Code