Skip to content

fix: use a new managed channel builder when creating channels#13684

Merged
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:pool
Jul 7, 2026
Merged

fix: use a new managed channel builder when creating channels#13684
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:pool

Conversation

@mutianf

@mutianf mutianf commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

ChannelPoolDpImpl calls the channel supplier many times over a pool's lifetime — at warm-up, on load-driven resize, on capacity misses in newStream, and on channel recycles.

gRPC builders are mutating: intercept(...) appends to an internal list, and build() snapshots the current list into the new channel. So if anything installs an interceptor on the shared builder between builds, that interceptor accumulates. If the interceptor includes any headers, this causes all the headers to accumulate.

@mutianf
mutianf requested review from a team as code owners July 7, 2026 18:57

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors SwitchingChannelPool to prevent interceptor accumulation by ensuring a fresh ManagedChannelBuilder is created for each channel supplier invocation, rather than reusing a single builder. It also adds a regression test to verify this behavior. The review feedback suggests improving the test teardown process by awaiting the termination of the server and executor to prevent potential thread leaks or port binding issues.

@mutianf
mutianf enabled auto-merge (squash) July 7, 2026 19:57
@mutianf
mutianf merged commit a049999 into googleapis:main Jul 7, 2026
209 of 211 checks passed
@mutianf
mutianf deleted the pool branch July 7, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants