15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_RETRY_POLICY_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_RETRY_POLICY_H
18 #include "google/cloud/spanner/internal/status_utils.h"
19 #include "google/cloud/spanner/version.h"
20 #include "google/cloud/internal/retry_policy.h"
21 #include "google/cloud/status.h"
22 #include "absl/strings/match.h"
26 namespace spanner_internal {
30 struct SafeGrpcRetry {
43 constexpr char const* kTransientFailureMessages[] = {
44 "Received unexpected EOS on DATA frame from server",
45 "Connection closed with unknown cause",
46 "HTTP/2 error code: INTERNAL_ERROR",
"RST_STREAM"};
47 for (
auto const& message : kTransientFailureMessages) {
48 if (absl::StrContains(status
.message(), message))
return true;
54 return !IsOk(status) && !IsTransientFailure(status);
59 struct SafeTransactionRerun {
67 return !IsOk(status) && !IsTransientFailure(status);
77 using RetryPolicy = ::
google::
cloud::internal::TraitBasedRetryPolicy<
78 spanner_internal::SafeGrpcRetry>;
81 using LimitedTimeRetryPolicy =
83 spanner_internal::SafeGrpcRetry>;
86 using LimitedErrorCountRetryPolicy =
87 google::
cloud::internal::LimitedErrorCountRetryPolicy<
88 spanner_internal::SafeGrpcRetry>;
91 using TransactionRerunPolicy = ::
google::
cloud::internal::TraitBasedRetryPolicy<
92 spanner_internal::SafeTransactionRerun>;
95 using LimitedTimeTransactionRerunPolicy =
97 spanner_internal::SafeTransactionRerun>;
100 using LimitedErrorCountTransactionRerunPolicy =
101 google::
cloud::internal::LimitedErrorCountRetryPolicy<
102 spanner_internal::SafeTransactionRerun>;