Skip to content

fix(bigtable): disable SwitchingChannelPool when ChannelPoolConfiguration is empty - #14911

Open
igorbernstein2 wants to merge 2 commits into
mainfrom
fix-switching-channel-pool-disabled-config
Open

igorbernstein2 wants to merge 2 commits into
mainfrom
fix-switching-channel-pool-disabled-config

Conversation

@igorbernstein2

Copy link
Copy Markdown
Contributor

Summary

When session_load == 0 across all scopes, ClientConfigurationManager.normalizeConfig clears session_configuration, resulting in an empty ChannelPoolConfiguration.getDefaultInstance().

This change updates SwitchingChannelPool to treat an empty ChannelPoolConfiguration (config.equals(ChannelPoolConfiguration.getDefaultInstance())) as disabled:

  • Delegates to a NoopChannelPool when disabled, which creates no underlying channels and immediately fails newStream with Status.UNAVAILABLE.
  • Transitions cleanly between disabled (NoopChannelPool) and enabled (ChannelPoolDpImpl / FallbackChannelPool / SingleChannelPool) on updateConfig via replaceChannelPool(createDelegate()), shutting down the active pool's channels when disabled.

@igorbernstein2
igorbernstein2 requested review from a team as code owners November 3, 2026 18:36

@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 introduces support for disabling the channel pool in SwitchingChannelPool by utilizing a new NoopChannelPool when the configuration is empty or default. It refactors delegate creation and config updates to seamlessly transition between enabled and disabled states, and adds a comprehensive test suite in SwitchingChannelPoolTest. The review feedback suggests a minor improvement in the test code to avoid reusing the same ArgumentCaptor instance across different mock verifications, which can lead to fragile tests.

Comment on lines +158 to +159
verify(secondListener).onClose(statusCaptor.capture(), any(Metadata.class));
assertThat(statusCaptor.getValue().getCode()).isEqualTo(Status.Code.UNAVAILABLE);

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.

medium

Reusing the same ArgumentCaptor instance (statusCaptor) across different mock verifications (streamListener and secondListener) is a code smell and can lead to fragile tests or unexpected behavior if the verifications are reordered or if multiple interactions occur. It is safer and cleaner to use a separate ArgumentCaptor instance for the second verification.

Suggested change
verify(secondListener).onClose(statusCaptor.capture(), any(Metadata.class));
assertThat(statusCaptor.getValue().getCode()).isEqualTo(Status.Code.UNAVAILABLE);
ArgumentCaptor<Status> secondStatusCaptor = ArgumentCaptor.forClass(Status.class);
verify(secondListener).onClose(secondStatusCaptor.capture(), any(Metadata.class));
assertThat(secondStatusCaptor.getValue().getCode()).isEqualTo(Status.Code.UNAVAILABLE);

This branch has not been deployed

No deployments
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.

1 participant