fix: per-subscriber write goroutines with 5s timeout (PILOT-278)#8
fix: per-subscriber write goroutines with 5s timeout (PILOT-278)#8matthew-pilot wants to merge 1 commit into
Conversation
…subscribers from stalling publisher (PILOT-278)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🦜 Matthew PR Check — #8 PILOT-278Status
CI Detail
VerdictCLEAN — per-subscriber write goroutines with 5s timeout prevent slow TCP subscribers from blocking the entire publish loop. 🤖 matthew-pr-worker · 2026-05-30T07:28Z |
🦜 Matthew Explains — #8 PILOT-278What this doesReplaces the sequential blocking write loop in Why it mattersBefore: After: Each subscriber gets its own goroutine with How it works
Files changed
CI noteClean — 2/2 green. Single-file change, well-tested. 🤖 matthew-pr-worker · 2026-05-30T07:28Z |
🦀 Matthew PR Check — #8 PILOT-278Status
What changedRewrote the |
🦀 Matthew Explains — #8 PILOT-278What this doesRewrites BeforeAfterWhy this mattersUnder real network conditions, a TCP subscriber with high latency or a stalled TCP window would block the entire publish loop. This consumed a publisher connection for the full TCP write timeout (often 30s+), preventing the publisher from reading new events and cascading into backpressure. Scope
|
Fix for PILOT-278
Bug: Slow TCP subscriber stalls the publishing goroutine in eventstream, consuming a publisher connection for the full TCP write timeout.
Root cause: publishWith() iterates subscribers sequentially with blocking writes. One TCP-stalled subscriber blocks the entire loop, preventing the publisher from reading new events.
Fix: Spawn each subscriber write in its own goroutine with a 5-second timeout (buffered channel + select). Slow subscribers are dropped after consecutive timeout failures, matching the existing resilience contract.
Changes
service.go: RewrotepublishWithdelivery loop to use per-subscriber goroutines with bounded timeoutpublishWriteTimeout = 5sconstantmaxConsecutivePublishFailuresthresholdVerification
go build ./...✓go vet ./...✓go test ./...✓ (0.222s)Scope
service.go)🔗 https://vulturelabs.atlassian.net/browse/PILOT-278