Skip to content

Conversation

@rahul2393
Copy link
Contributor

@rahul2393 rahul2393 commented Jan 12, 2026

Summary

  • Add connection URL properties to enable and configure Dynamic Channel Pooling (DCP)
  • Allow JDBC and Connection API users to opt-in to automatic gRPC channel scaling
  • Integrate DCP settings into SpannerPoolKey for proper connection pooling behavior

Details

This PR exposes the Dynamic Channel Pooling feature (already available in SpannerOptions)
through the Connection API and JDBC driver via connection URL properties.

New Connection Properties

Property Type Default Description
enableDynamicChannelPool boolean null (uses SpannerOptions default: false) Enable dynamic channel pooling
dcpMinChannels int null (uses SpannerOptions default: 2) Minimum channels in pool
dcpMaxChannels int null (uses SpannerOptions default: 10) Maximum channels in pool
dcpInitialChannels int null (uses SpannerOptions default: 4) Initial channels at startup

Example Usage

jdbc:cloudspanner:/projects/my-project/instances/my-instance/databases/my-db?enableDynamicChannelPool=true;dcpMinChannels=3;dcpMaxChannels=15

Important Notes

  • Setting numChannels disables DCP even if enableDynamicChannelPool=true
  • DCP requires gRPC-GCP extension (enabled by default)
  • When custom DCP channel options are specified, other DCP settings (RPC thresholds, intervals) use SpannerOptions defaults

@rahul2393 rahul2393 requested review from a team as code owners January 12, 2026 10:24
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Jan 12, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rahul2393, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for Dynamic Channel Pooling (DCP) within the Connection API, providing a mechanism for the Spanner client to automatically adjust the number of gRPC channels based on real-time load. This feature aims to optimize resource utilization and improve performance by ensuring that the client can scale its channel capacity up or down as needed, without manual intervention.

Highlights

  • Dynamic Channel Pooling (DCP) Configuration: Introduced new connection properties (enableDynamicChannelPool, dcpMinChannels, dcpMaxChannels, dcpInitialChannels) to allow users to configure dynamic gRPC channel scaling directly through the Connection API.
  • Spanner Client Integration: Integrated these new DCP properties into the SpannerPool to dynamically configure the underlying SpannerOptions for gRPC channel management, ensuring that channel scaling adapts to application load.
  • Comprehensive Testing: Added extensive unit tests for ConnectionOptions to validate the parsing of new DCP properties from connection URIs and for SpannerPool to confirm that different DCP settings correctly influence the pooling key and Spanner client creation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 adds support for Dynamic Channel Pooling (DCP) to the Spanner Connection API. The changes are well-implemented and include new connection properties, logic to configure the Spanner client with DCP settings, and corresponding tests. I have one suggestion to improve the maintainability of the code that configures the DCP options.

@rahul2393 rahul2393 requested a review from olavloite January 12, 2026 10:26
ENABLE_DYNAMIC_CHANNEL_POOL_PROPERTY_NAME,
"Enable dynamic channel pooling for automatic gRPC channel scaling. When enabled, the "
+ "client will automatically scale the number of channels based on load. Setting "
+ "numChannels will disable dynamic channel pooling even if this is set to true.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Would you mind adding something like `The default is SpannerOptions.DEFAULT_ENABLE_DYNAMIC_CHANNEL_POOL (false). This default will be changed to true in a future version.'? (At least, assuming that this is correct)

}
// Configure Dynamic Channel Pooling (DCP) if enabled.
// Note: Setting numChannels disables DCP even if enableDynamicChannelPool is true.
if (Boolean.TRUE.equals(key.enableDynamicChannelPool) && key.numChannels == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assumes that dynamic channel pooling is disabled by default. This is currently correct, but is likely to change in the future. Can we therefore either:

  1. Add explicit behavior here to disable DCP if enableDynamicChannelPool has been set to false?
  2. Or add a test to the Connection API that will fail if the default setting for DCP in the client library changes?

What I mean is the following:

  1. A user that sets enableDynamicChannelPool=true should always get DCP. This works fine now.
  2. A user that does not set a value for enableDynamicChannelPool should get the default of the client library. That works fine now, and the default is that it is disabled.
  3. A user that sets enableDynamicChannelPool=false should always get a fixed channel pool. That works now, but if the default in the client library changes, then they would all of a sudden get DCP.

}

@Test
public void testEnableDynamicChannelPool() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should also be a test for testDisableDynamicChannelPool

@rahul2393 rahul2393 requested a review from olavloite January 12, 2026 13:43
@rahul2393 rahul2393 merged commit bba03a4 into main Jan 12, 2026
43 checks passed
@rahul2393 rahul2393 deleted the connection-jdbc-support branch January 12, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants