Skip to content

fix(bigtable): disable connection pooling when emulator is set - #14483

Merged
bhshkh merged 4 commits into
googleapis:mainfrom
bhshkh:fix/disable-connection-pool-emulator
Apr 24, 2026
Merged

bhshkh merged 4 commits into
googleapis:mainfrom
bhshkh:fix/disable-connection-pool-emulator

Conversation

@bhshkh

@bhshkh bhshkh commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes issue #14480 . The fix automatically disables the custom connection pool whenever the BIGTABLE_EMULATOR_HOST environment variable is detected.

Root Cause

In recent versions (v1.26.0+), the custom Bigtable connection pool is enabled by default for production traffic . However, when BIGTABLE_EMULATOR_HOST is set, the client library initializes a single shared *grpc.ClientConn .

The custom connection pool expects to manage the lifecycle of multiple unique channels. Because the emulator uses a single pre-dialed connection, the pool's attempt to "prime" or manage multiple internal connections results in conflicts. Specifically, if the pool attempts to close or recycle a connection wrapper, it inadvertently closes the shared underlying gRPC connection for all other members of the pool, leading to errors such as rpc error: code = Canceled desc = grpc: the client connection is closing.

Changes

Modified google3/third_party/golang/cloud_google_com/go/bigtable/v/v1/internal/option/option.go:

  • Updated EnableBigtableConnectionPool to check for the BIGTABLE_EMULATOR_HOST environment variable .
  • If the emulator host is set, the function now returns false, ensuring the client falls back to the standard connection logic.

This change automates the current manual workaround of setting CBT_BIGTABLE_CONN_POOL=false when using the emulator .

Fixes: #14480

@bhshkh
bhshkh requested review from a team as code owners April 24, 2026 18:46
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Apr 24, 2026

@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 ensures that the Bigtable connection pool is disabled when the emulator is detected, as it is not supported in that environment. The changes include a new integration test for client initialization with the emulator and comprehensive unit tests for the connection pool enablement logic. The review feedback suggests updating the documentation for the EnableBigtableConnectionPool function to reflect this new behavior and adding a specific test case to confirm that the emulator setting correctly takes precedence over other environment variables.

Comment thread bigtable/internal/option/option.go Resolved
Comment thread bigtable/internal/option/option_test.go Resolved
Comment thread bigtable/integration_test.go Resolved
bhshkh and others added 2 commits April 24, 2026 13:45
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bhshkh
bhshkh enabled auto-merge (squash) April 24, 2026 20:46
@bhshkh
bhshkh merged commit a07a26b into googleapis:main Apr 24, 2026
12 of 13 checks passed
@bhshkh
bhshkh deleted the fix/disable-connection-pool-emulator branch April 24, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigtable: ConnectionPool doesn't work with emulator

3 participants

⌂ 换网址