fix(daemon): register echo + IPC bind accept loops on bgWG (PILOT-88)#407
Merged
Conversation
Two long-lived fire-and-forget goroutines — the echo service accept loop (startEchoService) and the IPC bind accept pusher (handleBind) — were spawned without registering on d.bgWG. During graceful shutdown, these goroutines check stopCh or rely on AcceptCh close to exit, but bgWG.Wait() in doStop had no visibility into them; only the 5s wall-clock timeout protected against shutdown races with shared state. Fix: add d.bgWG.Add(1) / defer d.bgWG.Done() around both accept loops so doStop tracks them alongside the existing 14 tracked background goroutines (routeLoop, trustRepublishLoop, etc.). Test: TestStartEchoServiceBGWaitGroupTracksAcceptLoop verifies that close(stopCh) drains bgWG within 2s. Closes PILOT-88
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.
What
Two long-lived fire-and-forget goroutines — the echo service accept loop (
startEchoService) and the IPC bind accept pusher (handleBind) — were spawned without registering ond.bgWG. During graceful shutdown, these goroutines checkstopChor rely onAcceptChclose to exit, butbgWG.Wait()indoStophad no visibility into them; only the 5s wall-clock timeout protected against shutdown races with shared state.Fix
Added
d.bgWG.Add(1)/defer d.bgWG.Done()around both accept loops sodoStoptracks them alongside the existing 14 tracked background goroutines.Verification
go build ./...— cleango vet ./...— cleango test -run TestStart ./pkg/daemon/— passesTestStartEchoServiceBGWaitGroupTracksAcceptLoop— new test verifyingclose(stopCh)drains bgWG within 2sCloses https://vulturelabs.atlassian.net/browse/PILOT-88