Skip to content

feat(bigtable): add lazyPool helper for on-demand session pool opening - #20182

Merged
sushanb merged 6 commits into
googleapis:mainfrom
sushanb:feat/bigtable-lazy-pool
Jul 21, 2026
Merged

sushanb merged 6 commits into
googleapis:mainfrom
sushanb:feat/bigtable-lazy-pool

Conversation

@sushanb

@sushanb sushanb commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds bigtable/internal/session with a lazyPool primitive that opens its underlying Invoker on first use. Concurrent callers block until the open completes; failed opens are NOT cached, so a transient proto.Marshal failure cannot strand the caller for the process lifetime.
  • A nil *lazyPool or one with a nil open closure returns (nil, nil), letting callers model "no session support, use fallback" (e.g., the write side of a read-only materialized view).
  • Adds transport.InvokeResult — the value type returned by Session.Invoke — so the session package can declare the Invoker interface without pulling in the full session-pool implementation, which will land in a follow-up.

Test plan

  • go build ./bigtable/internal/session/... ./bigtable/internal/transport/...
  • go vet ./bigtable/internal/session/... ./bigtable/internal/transport/...
  • go test ./bigtable/internal/session/... -run LazyPool -count=1 (both TestLazyPool_NilPoolAndNilOpenReturnNilNil and TestLazyPool_FailedOpenNotCached pass)
  • go test ./bigtable/internal/session/... -count=1 -race

Adds the internal `session` package with a `lazyPool` primitive that
opens its underlying Invoker on first use. Concurrent callers block
until the open completes; failed opens are NOT cached so a transient
proto.Marshal failure cannot strand the caller for the process
lifetime. A nil *lazyPool or one with a nil `open` closure returns
(nil, nil) so callers can model "no session support, use fallback"
(e.g., the write side of a read-only materialized view).

Also introduces `transport.InvokeResult` — the value type returned by
`Session.Invoke` — so the session package can declare the `Invoker`
interface without depending on the full session pool implementation
that will land in a follow-up.

Tests cover the nil-receiver / nil-open contract and the
failed-open-not-cached invariant (with the counterfactual counter).
@sushanb
sushanb requested review from a team as code owners July 21, 2026 19:41
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Jul 21, 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 introduces a lazyPool mechanism to lazily initialize session pools on first use, along with a struct InvokeResult to capture RPC outputs. The review feedback highlights a package name inconsistency in invoke_result.go (using internal instead of matching the directory or other files). Additionally, the reviewer recommends refactoring lazyPool to avoid holding an exclusive mutex during the slow, synchronous open() operation, suggesting a coordination channel instead to prevent blocking concurrent status checks.

Comment thread bigtable/internal/transport/invoke_result.go
Comment thread bigtable/internal/session/lazy_pool.go
Comment thread bigtable/internal/session/lazy_pool.go