Skip to content

impl(bigtable): enable directpath probe and cloudpath fallback - #16383

Draft
scotthart wants to merge 1 commit into
googleapis:mainfrom
scotthart:bigtable_directpath_enable_probe_diag
Draft

impl(bigtable): enable directpath probe and cloudpath fallback#16383
scotthart wants to merge 1 commit into
googleapis:mainfrom
scotthart:bigtable_directpath_enable_probe_diag

Conversation

@scotthart

Copy link
Copy Markdown
Member

No description provided.

@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Aug 25, 2026

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

Copy link
Copy Markdown

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 DataConnection creation to support DirectPath fallback and diagnostics, introduces helper functions for connection components, updates default timeouts, and adds integration tests for direct access compatibility metrics. The code review feedback highlights critical issues where completion queue threads are blocked by calling f.get() inside asynchronous lambdas, which can lead to thread starvation. Additionally, there are numerous style guide violations regarding the improper use of auto for obscured return types and primitive types, as well as an opportunity to avoid an unnecessary heap allocation in MetricsOperationContextFactory.

Comment on lines +267 to +268
components.background->cq().RunAsync(
[f = std::move(cp_future)]() mutable { (void)f.get(); });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Calling f.get() inside a RunAsync lambda blocks a completion queue thread. Completion queue threads are typically used for asynchronous event loops (like gRPC), and blocking them can lead to thread starvation or deadlocks. Instead, use .then() to attach a non-blocking continuation to the future.

    cp_future.then([](future<std::unique_ptr<bigtable_internal::StubManager>> f) { (void)f.get(); });

Comment on lines +285 to +286
components.background->cq().RunAsync(
[f = std::move(dp_future)]() mutable { (void)f.get(); });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Calling f.get() inside a RunAsync lambda blocks a completion queue thread. Completion queue threads are typically used for asynchronous event loops (like gRPC), and blocking them can lead to thread starvation or deadlocks. Instead, use .then() to attach a non-blocking continuation to the future.

  dp_future.then([](future<std::unique_ptr<bigtable_internal::StubManager>> f) { (void)f.get(); });

Comment on lines +125 to +126
auto limiter =
bigtable_internal::MakeMutateRowsLimiter(background->cq(), options);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used when it hides function return types. Please use the explicit type std::shared_ptr<MutateRowsLimiter> instead.

  std::shared_ptr<MutateRowsLimiter> limiter =
      bigtable_internal::MakeMutateRowsLimiter(background->cq(), options);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +66 to +67
auto metric_service_connection = monitoring_v3::MakeMetricServiceConnection(
bigtable::internal::MetricsExporterConnectionOptions(options));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide (Type Deduction section), auto should not be used when it hides function return types. Please use the explicit type std::shared_ptr<monitoring_v3::MetricServiceConnection> instead.

    std::shared_ptr<monitoring_v3::MetricServiceConnection> const
        metric_service_connection =
            monitoring_v3::MakeMetricServiceConnection(
                bigtable::internal::MetricsExporterConnectionOptions(options));
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +127 to +128
auto operation_context_factory =
MakeOperationContextFactory(options, instances);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used when it hides function return types. Please use the explicit type std::unique_ptr<OperationContextFactory> instead.

  std::unique_ptr<OperationContextFactory> operation_context_factory =
      MakeOperationContextFactory(options, instances);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +453 to +454
auto components = bigtable_internal::MakeDataConnectionComponents(
std::move(options), {}, __func__);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used when it hides function return types. Please use the explicit type bigtable_internal::DataConnectionComponents instead.

  bigtable_internal::DataConnectionComponents components =
      bigtable_internal::MakeDataConnectionComponents(std::move(options), {},
                                                      __func__);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +32 to +34
constexpr auto DefaultDirectPathDataEndpoint() {
return "google-c2p:///bigtable.googleapis.com";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used for primitive or scalar types (including pointer types like char const*). Please use char const* explicitly.

constexpr char const* DefaultDirectPathDataEndpoint() {
  return "google-c2p:///bigtable.googleapis.com";
}
References
  1. Disallow auto for Primitives: Require explicit numeric and scalar types (std::size_t, std::int64_t, bool, etc.) rather than deducing them from literals. (link)

Comment on lines +36 to +38
constexpr auto DefaultDirectPathAuthority() {
return "bigtable.googleapis.com";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used for primitive or scalar types (including pointer types like char const*). Please use char const* explicitly.

constexpr char const* DefaultDirectPathAuthority() {
  return "bigtable.googleapis.com";
}
References
  1. Disallow auto for Primitives: Require explicit numeric and scalar types (std::size_t, std::int64_t, bool, etc.) rather than deducing them from literals. (link)

virtual DiagnosticFailureReason CheckLoopbackConfiguration() = 0;
};

constexpr auto DefaultDirectPathMetadataHost() { return "169.254.169.254"; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, auto should not be used for primitive or scalar types (including pointer types like char const*). Please use char const* explicitly.

constexpr char const* DefaultDirectPathMetadataHost() { return "169.254.169.254"; }
References
  1. Disallow auto for Primitives: Require explicit numeric and scalar types (std::size_t, std::int64_t, bool, etc.) rather than deducing them from literals. (link)

Comment on lines +358 to +362
auto metric = std::make_shared<DirectAccessCompatibility>(
kBigtableMetricNamePath, provider_);
direct_access_compatibility_ = std::shared_ptr<DirectAccessCompatibility>(
static_cast<DirectAccessCompatibility*>(
metric->clone(client_resource_labels_).release()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Creating a std::shared_ptr via std::make_shared just to call clone on it and immediately discard it introduces an unnecessary heap allocation. Since DirectAccessCompatibility can be constructed on the stack, you can allocate it on the stack instead.

  DirectAccessCompatibility metric(kBigtableMetricNamePath, provider_);
  direct_access_compatibility_ = std::shared_ptr<DirectAccessCompatibility>(
      static_cast<DirectAccessCompatibility*>(
          metric.clone(client_resource_labels_).release()));

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.84746% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.24%. Comparing base (5c916cf) to head (a14deab).

Files with missing lines Patch % Lines
...d/bigtable/tests/observability_integration_test.cc 7.50% 74 Missing ⚠️
google/cloud/bigtable/data_connection.cc 83.33% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16383      +/-   ##
==========================================
- Coverage   92.28%   92.24%   -0.04%     
==========================================
  Files        2245     2246       +1     
  Lines      211685   211847     +162     
==========================================
+ Hits       195349   195419      +70     
- Misses      16336    16428      +92     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart
scotthart force-pushed the bigtable_directpath_enable_probe_diag branch 2 times, most recently from 766cf9d to 0622850 Compare August 25, 2026 18:32
@scotthart
scotthart force-pushed the bigtable_directpath_enable_probe_diag branch from 0622850 to a14deab Compare August 25, 2026 19:30
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.

1 participant