Repository navigation
Conversation
…inish Pass enable_server_retries_ to BulkMutatorState::OnFinish in AsyncBulkApplier::OnFinish so unconfirmed non-idempotent mutations are retried when server retries are enabled and the MutateRows stream status carries google.rpc.RetryInfo. Remove the default false argument on BulkMutatorState::OnFinish to prevent callers from omitting it.
There was a problem hiding this comment.
Code Review
This pull request updates AsyncBulkApplier and BulkMutatorState to propagate the enable_server_retries flag during bulk apply operations. In compliance with the repository style guide, default parameters in the internal namespace have been removed from OnFinish, requiring callers to explicitly specify the retry behavior. Additionally, comprehensive unit tests have been added to verify that server retries are correctly handled or ignored for non-idempotent mutations. The review feedback highlights several violations of the style guide regarding the use of auto where it obscures domain types, return types, or protobuf messages, suggesting explicit types instead.
| }); | ||
| CompletionQueue cq(mock_cq); | ||
|
|
||
| auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::unique_ptr<bigtable::RPCRetryPolicy> instead.
std::unique_ptr<bigtable::RPCRetryPolicy> retry =
DataLimitedErrorCountRetryPolicy(kNumRetries).clone();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone(); | ||
| auto mock_b = std::make_unique<MockBackoffPolicy>(); | ||
| EXPECT_CALL(*mock_b, OnCompletion).Times(2); | ||
| auto idempotency = bigtable::DefaultIdempotentMutationPolicy(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<bigtable::IdempotentMutationPolicy> instead.
std::shared_ptr<bigtable::IdempotentMutationPolicy> idempotency =
bigtable::DefaultIdempotentMutationPolicy();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| EXPECT_CALL(*mock_b, OnCompletion).Times(2); | ||
| auto idempotency = bigtable::DefaultIdempotentMutationPolicy(); | ||
|
|
||
| auto actual = AsyncBulkApplier::Create( |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type google::cloud::future<std::vector<bigtable::FailedMutation>> instead.
google::cloud::future<std::vector<bigtable::FailedMutation>> actual =
AsyncBulkApplier::Create(References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| EXPECT_CALL(*mock_cq, MakeRelativeTimer).Times(0); | ||
| CompletionQueue cq(mock_cq); | ||
|
|
||
| auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::unique_ptr<bigtable::RPCRetryPolicy> instead.
std::unique_ptr<bigtable::RPCRetryPolicy> retry =
DataLimitedErrorCountRetryPolicy(kNumRetries).clone();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone(); | ||
| auto mock_b = std::make_unique<MockBackoffPolicy>(); | ||
| EXPECT_CALL(*mock_b, OnCompletion).Times(0); | ||
| auto idempotency = bigtable::DefaultIdempotentMutationPolicy(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<bigtable::IdempotentMutationPolicy> instead.
std::shared_ptr<bigtable::IdempotentMutationPolicy> idempotency =
bigtable::DefaultIdempotentMutationPolicy();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| EXPECT_CALL(*mock_b, OnCompletion).Times(0); | ||
| auto idempotency = bigtable::DefaultIdempotentMutationPolicy(); | ||
|
|
||
| auto actual = AsyncBulkApplier::Create( |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type google::cloud::future<std::vector<bigtable::FailedMutation>> instead.
google::cloud::future<std::vector<bigtable::FailedMutation>> actual =
AsyncBulkApplier::Create(References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| } | ||
|
|
||
| TEST_F(BulkMutatorTest, StateOnFinishServerRetries) { | ||
| auto policy = DefaultIdempotentMutationPolicy(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<IdempotentMutationPolicy> instead.
std::shared_ptr<IdempotentMutationPolicy> policy =
DefaultIdempotentMutationPolicy();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| auto retry_status = | ||
| google::cloud::internal::ResourceExhaustedError("try again"); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type Status instead.
Status retry_status =
google::cloud::internal::ResourceExhaustedError("try again");References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| bigtable_internal::BulkMutatorState state_enabled( | ||
| kAppProfile, kTableName, *policy, | ||
| BulkMutation(NonIdempotentMutation("r0"), NonIdempotentMutation("r1"))); | ||
| auto const& req1 = state_enabled.BeforeStart(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it hides protobuf messages. Please use the explicit type google::bigtable::v2::MutateRowsRequest const& instead.
google::bigtable::v2::MutateRowsRequest const& req1 =
state_enabled.BeforeStart();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
| state_enabled.OnRead(MakeResponse({{0, grpc::StatusCode::OK}})); | ||
| state_enabled.OnFinish(retry_status, /*enable_server_retries=*/true); | ||
| EXPECT_TRUE(state_enabled.HasPendingMutations()); | ||
| auto const& req2 = state_enabled.BeforeStart(); |
There was a problem hiding this comment.
According to the style guide, auto should not be used when it hides protobuf messages. Please use the explicit type google::bigtable::v2::MutateRowsRequest const& instead.
google::bigtable::v2::MutateRowsRequest const& req2 =
state_enabled.BeforeStart();References
- Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)
There was a problem hiding this comment.
Addressed in 8127c9b: replaced auto with the explicit return type.
|
Addressed the review comments in 8127c9b: replaced |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16739 +/- ##
==========================================
+ Coverage 92.85% 92.87% +0.01%
==========================================
Files 2279 2279
Lines 230285 230423 +138
==========================================
+ Hits 213839 213995 +156
+ Misses 16446 16428 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
scotthart
left a comment
There was a problem hiding this comment.
Re-checked at 8127c9bad5: the production fix in AsyncBulkApplier::OnFinish, the removal of the = false default parameter on BulkMutatorState::OnFinish, and the explicit type cleanup in 8127c9bad5 all look good.
One remaining suggestion on google/cloud/bigtable/internal/async_bulk_apply_test.cc:742-800 (RetryInfoIgnoredNonIdempotent): because StatusCode::kResourceExhausted is treated as permanent by SafeGrpcRetry, internal::Backoff(..., /*enable_server_retries=*/false) stops retries even if AsyncBulkApplier::OnFinish passed true to state_.OnFinish. Using TransientError() (StatusCode::kUnavailable) with RetryInfo (or adding a test case for it) ensures the test specifically verifies that state_.OnFinish receives enable_server_retries_ == false and does not keep the unconfirmed non-idempotent mutation pending.
|
Addressed the review comment in
|
Summary
enable_server_retries_toBulkMutatorState::OnFinishinAsyncBulkApplier::OnFinishso unconfirmed non-idempotent mutations are retried when server retries are enabled and theMutateRowsstream status carriesgoogle.rpc.RetryInfo.= falseargument onBulkMutatorState::OnFinishso callers must explicitly passenable_server_retries.Testing
google/cloud/bigtable/internal/async_bulk_apply_test.ccandgoogle/cloud/bigtable/internal/bulk_mutator_test.cc.bazel test //google/cloud/bigtable:internal_async_bulk_apply_test //google/cloud/bigtable:internal_bulk_mutator_test.