TLDR: we would like to have the conversion of GRPC::BadStatus errors to Google::Cloud::Errors in the Enumerable result of streaming calls of the spanner client, so that the consumer only has to deal with one kind of error.
We are currently observing a problem when calling the streaming calls in the spanner client Google::Cloud::Spanner::V1::Client where we have to handle both Google::Cloud::Errors and GRPC::Errors.
The generated client is rescuing GRPC::BadStatus and converting those to Google::Cloud::Errors (like here). That is fine, because we can rely that if we get a GRPC::BadStatus it will be automatically converted to us when executing the method.
The problem lies in handling the result of streaming calls. The generated client is returning Enumerable<PartialResultSet> (as specified here). If we call result.next we might get GRPC::BadStatus errors, because in this stream of results there is no conversion from GRPC::BadStatus errors to Google::Cloud::Errors. This makes it a bit clunky to deal with the errors, where we have to deal with both flavours of the same errors.
This problem is exemplified below:
require "google/cloud/spanner/v1"
client = V1::Spanner::Client.new
begin
result = client.execute_streaming_sql request, opts # This can raise a Google::Cloud::Error
result.next # This can raise a GRPC::BadStatus (or other GRPC errors)
rescue GRPC::Unavailable, Google::Cloud::UnavailableError => err # Must rescue both
puts err
end
We have identified this problem when fixing long PDML transactions in the ruby spanner client library (googleapis/google-cloud-ruby#7592).
TLDR: we would like to have the conversion of
GRPC::BadStatuserrors toGoogle::Cloud::Errors in theEnumerableresult of streaming calls of the spanner client, so that the consumer only has to deal with one kind of error.We are currently observing a problem when calling the streaming calls in the spanner client
Google::Cloud::Spanner::V1::Clientwhere we have to handle bothGoogle::Cloud::Errors andGRPC::Errors.The generated client is rescuing
GRPC::BadStatusand converting those toGoogle::Cloud::Errors (like here). That is fine, because we can rely that if we get aGRPC::BadStatusit will be automatically converted to us when executing the method.The problem lies in handling the result of streaming calls. The generated client is returning
Enumerable<PartialResultSet>(as specified here). If we callresult.nextwe might getGRPC::BadStatuserrors, because in this stream of results there is no conversion fromGRPC::BadStatuserrors toGoogle::Cloud::Errors. This makes it a bit clunky to deal with the errors, where we have to deal with both flavours of the same errors.This problem is exemplified below:
We have identified this problem when fixing long PDML transactions in the ruby spanner client library (googleapis/google-cloud-ruby#7592).