Skip to content

Commit dfeb79f

Browse files
author
Chris Rossi
authored
fix: add ABORTED to retryable status codes (#391)
Fixes #383.
1 parent 8bf9f67 commit dfeb79f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/google-cloud-ndb/google/cloud/ndb/_retry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ def retry_wrapper(*args, **kwargs):
9999
# that a DEADLINE_EXCEEDED status code guarantees the operation was cancelled,
100100
# then we can add DEADLINE_EXCEEDED to our retryable status codes. Not knowing
101101
# the answer, it's best not to take that risk.
102-
TRANSIENT_CODES = (grpc.StatusCode.UNAVAILABLE, grpc.StatusCode.INTERNAL)
102+
TRANSIENT_CODES = (
103+
grpc.StatusCode.UNAVAILABLE,
104+
grpc.StatusCode.INTERNAL,
105+
grpc.StatusCode.ABORTED,
106+
)
103107

104108

105109
def is_transient_error(error):

packages/google-cloud-ndb/tests/unit/test__retry.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,11 @@ def test_unauthenticated(core_retry):
177177
core_retry.if_transient_error.return_value = False
178178
assert _retry.is_transient_error(error) is False
179179
core_retry.if_transient_error.assert_called_once_with(error)
180+
181+
@staticmethod
182+
@mock.patch("google.cloud.ndb._retry.core_retry")
183+
def test_aborted(core_retry):
184+
error = mock.Mock(code=mock.Mock(return_value=grpc.StatusCode.ABORTED))
185+
core_retry.if_transient_error.return_value = False
186+
assert _retry.is_transient_error(error) is True
187+
core_retry.if_transient_error.assert_called_once_with(error)

0 commit comments

Comments
 (0)