Skip to content

fix(dispatch): close secondary grpc connections on shutdown#3141

Open
immanuwell wants to merge 1 commit into
authzed:mainfrom
immanuwell:fix/close-secondary-dispatch-conns
Open

fix(dispatch): close secondary grpc connections on shutdown#3141
immanuwell wants to merge 1 commit into
authzed:mainfrom
immanuwell:fix/close-secondary-dispatch-conns

Conversation

@immanuwell

@immanuwell immanuwell commented May 28, 2026

Copy link
Copy Markdown

SecondaryDispatch only stored the client interface, not the underlying conn, so Close() left secondary grpc connections dangling on shutdown.

Added a Conn field to SecondaryDispatch, stored it in combined.go, and updated Close() to drain secondaries before the primary. Field is nil-safe so test doubles are unaffected.

To reproduce: start with --dispatch-secondary-upstream-addr, shut down cleanly, secondary grpc goroutines (keep-alive etc) outlive the shutdown sequence.

@immanuwell immanuwell requested a review from a team as a code owner May 28, 2026 07:55
@github-actions github-actions Bot added the area/dispatch Affects dispatching of requests label May 28, 2026
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@immanuwell

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

authzedbot added a commit to authzed/cla that referenced this pull request May 28, 2026

@tstirrat15 tstirrat15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall gist makes sense to me. Is it possible to write a unit test that captures this behavior, perhaps using a goleak assertion?

}

func (cr *clusterDispatcher) Close() error {
var firstErr error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer errors.Join here

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.45455% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/dispatch/remote/cluster.go 50.00% 4 Missing and 1 partial ⚠️
internal/dispatch/combined/combined.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@miparnisari miparnisari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! This LGTM, but I have a few questions:

@miparnisari miparnisari force-pushed the fix/close-secondary-dispatch-conns branch from 4067dc5 to 679f3f5 Compare June 19, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dispatch Affects dispatching of requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants