-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(spanner): add Options save/restore to PartialResultSetSource #8355
fix(spanner): add Options save/restore to PartialResultSetSource #8355
Conversation
Save the options in force during `PartialResultSetSource` construction, and then restore them over `PartialResultSetReader` calls. This means that `NextRow()`, `Finish()` and `TryCancel()` will have the right options installed during any RPCs they execute. Tighten up the test by installing a non-matching `OptionsSpan` before any `NextRow()` calls are made, and by expecting no `TryCancel()`s in cases that complete their enumeration. This is the Spanner equivalent of googleapis#8256.
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
Codecov Report
@@ Coverage Diff @@
## main #8355 +/- ##
=======================================
Coverage 94.99% 94.99%
=======================================
Files 1355 1355
Lines 120749 120790 +41
=======================================
+ Hits 114700 114748 +48
+ Misses 6049 6042 -7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got me thinking, should we make analogous changes to the resumable streaming RPC:
google-cloud-cpp/google/cloud/internal/resumable_streaming_read_rpc.h
Lines 93 to 99 in 18082df
absl::variant<Status, ResponseType> Read() override { | |
auto response = impl_->Read(); | |
if (absl::holds_alternative<ResponseType>(response)) { | |
updater_(absl::get<ResponseType>(response), request_); | |
has_received_data_ = true; | |
return response; | |
} |
EXPECT_CALL(*grpc_reader, Finish()).WillOnce(Return(Status())); | ||
|
||
auto reader = PartialResultSetSource::Create(std::move(grpc_reader)); | ||
.WillOnce([&response] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional:
auto make_read_mock = [&response](int i) {
return [&response, i]() {
EXPECT_EQ(internal::CurrentOptions().get<StringOption>(), "ErrorOnIncompleteRow");
return response[i];
}
};
EXPECT_CALL(*grpc_reader, Read)
.WillOnce(make_read_mock(0))
.WillOnce(make_read_mock(1))
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I did something similar that eliminates the duplication and makes the mocks easier to use and understand. PTAL.
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
I'll look into it. |
I had thought that the |
I don't think there was really a hole, as destroying the unfinished streaming reader only calls directly into gRPC to try to cancel the stream. That is, there is no cancellation RPC or other code that might look at our |
I was thinking about |
Save the options in force during
PartialResultSetSource
construction,and then restore them over
PartialResultSetReader
calls. This meansthat
NextRow()
,Finish()
andTryCancel()
will have the rightoptions installed during any RPCs they execute.
Tighten up the test by installing a non-matching
OptionsSpan
beforeany
NextRow()
calls are made, and by expecting noTryCancel()
s incases that complete their enumeration.
This is the Spanner equivalent of #8256.
This change is