Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ private static boolean isRetryable(ErrorCode code, @Nullable Throwable cause) {
return hasCauseMatching(cause, Matchers.isRetryableInternalError);
case UNAVAILABLE:
return true;
case RESOURCE_EXHAUSTED:
return true;
default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ TransactionSelector getTransactionSelector() {

@Override
public void onError(SpannerException e) {
if (e.getErrorCode() == ErrorCode.ABORTED) {
if (e.getErrorCode() == ErrorCode.ABORTED
|| e.getErrorCode() == ErrorCode.RESOURCE_EXHAUSTED) {
long delay = -1L;
if (e instanceof AbortedException) {
delay = ((AbortedException) e).getRetryDelayInMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public void runAbortNoRetryInfo() {
assertThat(backoffMillis.getValue()).isGreaterThan(0L);
}

@Test
public void runResourceExhausted() {
runTransaction(new StatusRuntimeException(Status.fromCodeValue(Status.Code.RESOURCE_EXHAUSTED.value())));
ArgumentCaptor<Long> backoffMillis = ArgumentCaptor.forClass(Long.class);
verify(sleeper, times(1)).backoffSleep(Mockito.<Context>any(), backoffMillis.capture());
assertThat(backoffMillis.getValue()).isGreaterThan(0L);
}

@Test
public void commitAbort() {
final SpannerException error =
Expand Down