Skip to content

feat(bigtable): Use connection factory to create connection and require connections to be primed.#13755

Merged
sushanb merged 13 commits intogoogleapis:mainfrom
sushanb:prime_
Feb 7, 2026
Merged

feat(bigtable): Use connection factory to create connection and require connections to be primed.#13755
sushanb merged 13 commits intogoogleapis:mainfrom
sushanb:prime_

Conversation

@sushanb
Copy link
Copy Markdown
Contributor

@sushanb sushanb commented Feb 3, 2026

lift and sift of sushanb#5

@sushanb sushanb requested review from a team and nimf February 3, 2026 02:58
@sushanb sushanb requested a review from a team as a code owner February 3, 2026 02:58
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Feb 3, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @sushanb, 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 significantly refactors the Bigtable connection pooling by abstracting connection creation and priming into a dedicated connectionFactory. This change centralizes critical connection setup logic, making it more robust through the introduction of a retry mechanism for priming. The BigtableChannelPool now delegates connection instantiation to this factory, leading to cleaner code and improved reliability in establishing and maintaining connections.

Highlights

  • Connection Factory Introduction: A new connectionFactory struct has been introduced to centralize the logic for creating and priming Bigtable connections, ensuring all connections are properly initialized before use.
  • Robust Connection Priming: The connectionFactory now includes a primeWithRetry method that attempts to prime connections with exponential backoff and up to 3 retries, significantly improving resilience to transient connection issues.
  • Refactored Connection Pool: The BigtableChannelPool has been updated to utilize the new connectionFactory for all connection creation scenarios, including initial pool setup, connection replacement, and scaling up, simplifying its internal implementation.
  • Enhanced Test Infrastructure: The fakeService in test helpers has been modified to support simulating multiple priming errors, and new test cases have been added to thoroughly validate the connectionFactory's retry mechanism and context handling.
Changelog
  • bigtable/go.mod
    • Added github.com/googleapis/gax-go/v2 dependency.
    • Introduced a duplicate toolchain go1.25.5 entry.
  • bigtable/internal/transport/connpool.go
    • Defined connectionFactory struct to manage connection dialing and priming.
    • Implemented newEntry method within connectionFactory to create and prime a connEntry.
    • Added primeWithRetry method to connectionFactory for priming connections with exponential backoff.
    • Modified BigtableChannelPool to use connectionFactory for initial connection setup, replacement, and scaling, removing direct priming calls.
  • bigtable/internal/transport/connpool_helper_test.go
    • Replaced pingErr with pingErrs (a slice of errors) in fakeService to allow for sequential error simulation during priming.
    • Updated setPingErr to accept variadic errors.
    • Modified PingAndWarm to use the pingErrs slice and capture metadata only on the first call.
    • Added getPingCallCount to fakeService for tracking PingAndWarm invocations.
  • bigtable/internal/transport/connpool_synctest_test.go
    • Imported google.golang.org/grpc/codes, google.golang.org/grpc/metadata, and google.golang.org/grpc/status.
    • Added TestConnectionFactoryWithSyncTest to test connectionFactory behavior, particularly concerning context timeouts during backoff.
  • bigtable/internal/transport/connpool_test.go
    • Introduced TestConnectionFactory with comprehensive test cases for various scenarios, including successful priming, dial errors, successful retries, failed retries, and context cancellation.
    • Adjusted existing tests (TestBigtableConn_Prime, TestReplaceConnection, TestAddConnections) to integrate with the new connectionFactory and fakeService changes.
Activity
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
Copy Markdown
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 refactors the connection creation logic by introducing a connectionFactory. This is a great improvement as it centralizes connection creation and priming, and adds retry logic with backoff for priming connections, making the connection pool more robust. The changes are well-tested with updates to existing tests and new tests for the factory.

I've found a couple of minor issues: a duplicated line in go.mod and a leftover debug print statement in the new connection factory logic. Please see the detailed comments.

Comment thread bigtable/internal/transport/connpool.go Outdated
Comment thread bigtable/go.mod Outdated
@sushanb sushanb requested a review from a team as a code owner February 4, 2026 02:11
Copy link
Copy Markdown
Contributor

@nimf nimf left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread bigtable/internal/transport/connpool.go
wantPrimeCalls int
}{
{
name: "Timeout During Backoff",
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.

why this one is in connpool_synctest_test and the others in connpool_test?

Comment thread bigtable/internal/transport/connpool_test.go
@sushanb sushanb merged commit b08ea15 into googleapis:main Feb 7, 2026
12 checks passed
bhshkh added a commit that referenced this pull request Mar 16, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.8.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:19bb93e8f1f916c61b597db2bad65dc432f79baaabb210499d7d0e4ad1dffe29
<details><summary>bigtable: 1.43.0</summary>

##
[1.43.0](bigtable/v1.42.0...bigtable/v1.43.0)
(2026-03-16)

### Features

* Add support for creating Instance with tags (#13459)
([1bce843](1bce843e))

* support tiered storage (#13793)
([39a25b9](39a25b92))

* add handling of longupdown metrics aka gauge (#13871)
([519ed9b](519ed9b0))

* Use direct access when supported. Guarded by enabling… (#13873)
([5ea1f5f](5ea1f5f9))

* add preemptive connection recycler (#13860)
([6b69ee3](6b69ee38))

* make downscalling less aggressive (#14123)
([7ac72cc](7ac72cc8))

* add pacemaker in connpool (#13862)
([9af047f](9af047f7))

* populate ip protocol for direct access checker and rename a method to
be concise (#14011)
([9c5e655](9c5e6551))

* add connection factory to abstract connection (#13755)
([b08ea15](b08ea15f))

* make pow of 2 default lb policy (#14131)
([b5f7bf2](b5f7bf27))

* derive conn pool from resolver (#14147)
([b903e29](b903e299))

* add load balancing penalty for channel (#14149)
([bb64998](bb649988))

* cap increase in conn for dynamic chan pool (#14144)
([e0701a4](e0701a46))

* switch to rand v2 (#14008)
([ee6f425](ee6f4251))

### Bug Fixes

* slighly change instruction for direct access (#14119)
([7dd4948](7dd4948d))

* refactor bigtable.go into separate file path per interfaces (#13818)
([c8ae2e2](c8ae2e2a))

</details>
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.

2 participants