Skip to content

Commit 654c3dc

Browse files
authored
fix(storage): make sure to send append_object_spec when retrying (#15160)
1 parent 7d3feab commit 654c3dc

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

google/cloud/storage/internal/async/connection_impl.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,16 @@ AsyncConnectionImpl::ReadObjectRange(ReadObjectParams p) {
296296

297297
future<StatusOr<std::unique_ptr<storage_experimental::AsyncWriterConnection>>>
298298
AsyncConnectionImpl::StartAppendableObjectUpload(AppendableUploadParams p) {
299-
return AppendableObjectUploadImpl(std::move(p), AppendMode::kStart);
299+
return AppendableObjectUploadImpl(std::move(p));
300300
}
301301

302302
future<StatusOr<std::unique_ptr<storage_experimental::AsyncWriterConnection>>>
303303
AsyncConnectionImpl::ResumeAppendableObjectUpload(AppendableUploadParams p) {
304-
return AppendableObjectUploadImpl(std::move(p), AppendMode::kTakeover);
304+
return AppendableObjectUploadImpl(std::move(p));
305305
}
306306

307307
future<StatusOr<std::unique_ptr<storage_experimental::AsyncWriterConnection>>>
308-
AsyncConnectionImpl::AppendableObjectUploadImpl(AppendableUploadParams p,
309-
AppendMode mode) {
308+
AsyncConnectionImpl::AppendableObjectUploadImpl(AppendableUploadParams p) {
310309
auto current = internal::MakeImmutableOptions(std::move(p.options));
311310
auto request = std::move(p.request);
312311
std::int64_t persisted_size = 0;
@@ -329,9 +328,9 @@ AsyncConnectionImpl::AppendableObjectUploadImpl(AppendableUploadParams p,
329328
auto factory = WriteResultFactory(
330329
[stub = stub_, cq = cq_, retry = std::move(retry),
331330
// NOLINTNEXTLINE(bugprone-lambda-function-name)
332-
backoff = std::move(backoff), current, function_name = __func__,
333-
mode](google::storage::v2::BidiWriteObjectRequest req) {
334-
auto call = [stub, request = std::move(req), mode](
331+
backoff = std::move(backoff), current, function_name = __func__](
332+
google::storage::v2::BidiWriteObjectRequest req) {
333+
auto call = [stub, request = std::move(req)](
335334
CompletionQueue& cq,
336335
std::shared_ptr<grpc::ClientContext> context,
337336
google::cloud::internal::ImmutableOptions options,
@@ -345,10 +344,10 @@ AsyncConnectionImpl::AppendableObjectUploadImpl(AppendableUploadParams p,
345344
auto per_write_timeout = start_timeout;
346345

347346
// Apply the routing header
348-
if (mode == AppendMode::kTakeover)
349-
ApplyRoutingHeaders(*context, request.append_object_spec());
350-
else
347+
if (request.has_write_object_spec())
351348
ApplyRoutingHeaders(*context, request.write_object_spec());
349+
else
350+
ApplyRoutingHeaders(*context, request.append_object_spec());
352351

353352
auto rpc = stub->AsyncBidiWriteObject(cq, std::move(context),
354353
std::move(options));

google/cloud/storage/internal/async/connection_impl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ class AsyncConnectionImpl
108108
return shared_from_this();
109109
}
110110

111-
enum class AppendMode { kStart, kTakeover };
112-
113111
future<StatusOr<google::storage::v2::StartResumableWriteResponse>>
114112
StartResumableWrite(internal::ImmutableOptions current,
115113
google::storage::v2::StartResumableWriteRequest request);
@@ -143,7 +141,7 @@ class AsyncConnectionImpl
143141
std::int64_t persisted_size);
144142

145143
future<StatusOr<std::unique_ptr<storage_experimental::AsyncWriterConnection>>>
146-
AppendableObjectUploadImpl(AppendableUploadParams p, AppendMode mode);
144+
AppendableObjectUploadImpl(AppendableUploadParams p);
147145

148146
CompletionQueue cq_;
149147
std::shared_ptr<GrpcChannelRefresh> refresh_;

0 commit comments

Comments
 (0)