impl(bigtable): enable directpath probe and cloudpath fallback - #16383
impl(bigtable): enable directpath probe and cloudpath fallback#16383scotthart wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
| components.background->cq().RunAsync( | ||
| [f = std::move(cp_future)]() mutable { (void)f.get(); }); |
There was a problem hiding this comment.
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(); });| components.background->cq().RunAsync( | ||
| [f = std::move(dp_future)]() mutable { (void)f.get(); }); |
There was a problem hiding this comment.
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(); });| auto limiter = | ||
| bigtable_internal::MakeMutateRowsLimiter(background->cq(), options); |
There was a problem hiding this comment.
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
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
| auto metric_service_connection = monitoring_v3::MakeMetricServiceConnection( | ||
| bigtable::internal::MetricsExporterConnectionOptions(options)); |
There was a problem hiding this comment.
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
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
| auto operation_context_factory = | ||
| MakeOperationContextFactory(options, instances); |
There was a problem hiding this comment.
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
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
| auto components = bigtable_internal::MakeDataConnectionComponents( | ||
| std::move(options), {}, __func__); |
There was a problem hiding this comment.
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
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
| constexpr auto DefaultDirectPathDataEndpoint() { | ||
| return "google-c2p:///bigtable.googleapis.com"; | ||
| } |
There was a problem hiding this comment.
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
- 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)
| constexpr auto DefaultDirectPathAuthority() { | ||
| return "bigtable.googleapis.com"; | ||
| } |
There was a problem hiding this comment.
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
- 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"; } |
There was a problem hiding this comment.
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
- 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)
| auto metric = std::make_shared<DirectAccessCompatibility>( | ||
| kBigtableMetricNamePath, provider_); | ||
| direct_access_compatibility_ = std::shared_ptr<DirectAccessCompatibility>( | ||
| static_cast<DirectAccessCompatibility*>( | ||
| metric->clone(client_resource_labels_).release())); |
There was a problem hiding this comment.
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
766cf9d to
0622850
Compare
0622850 to
a14deab
Compare
No description provided.