Skip to content
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

smallFixForGoneAndRetryPolicy #24642

Merged
merged 1 commit into from
Oct 8, 2021
Merged
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 @@ -54,11 +54,11 @@ public Mono<ShouldRetryResult> shouldRetry(Exception exception) {

return this.retryWithRetryPolicy.shouldRetry(exception)
.flatMap((retryWithResult) -> {

if (retryWithResult.shouldRetry) {
if (!retryWithResult.nonRelatedException) {
return Mono.just(retryWithResult);
}

// only pass request to gone retry policy if retryWithRetryPolicy can not handle the exception.
return this.goneRetryPolicy.shouldRetry(exception)
.flatMap((goneRetryResult) -> {
if (!goneRetryResult.shouldRetry) {
Expand Down Expand Up @@ -109,7 +109,6 @@ public GoneRetryPolicy(

private boolean isNonRetryableException(Exception exception) {
if (exception instanceof GoneException ||
exception instanceof RetryWithException ||
exception instanceof PartitionIsMigratingException ||
exception instanceof PartitionKeyRangeIsSplittingException) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
import com.azure.cosmos.implementation.PartitionKeyRangeIsSplittingException;
import com.azure.cosmos.implementation.RequestTimeoutException;
import com.azure.cosmos.implementation.ResourceType;
import com.azure.cosmos.implementation.RetryWithException;
import com.azure.cosmos.implementation.RxDocumentServiceRequest;
import com.azure.cosmos.implementation.ShouldRetryResult;
import com.azure.cosmos.implementation.guava25.base.Supplier;
import org.mockito.Mockito;
import org.testng.annotations.Test;
import reactor.core.publisher.Mono;

import java.time.Duration;

import static com.azure.cosmos.implementation.TestUtils.mockDiagnosticsClientContext;
import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -321,4 +325,22 @@ public void shouldRetryWithGenericException() {
assertThat(shouldRetryResult.shouldRetry).isFalse();
}

/**
* After waitTimeInSeconds exhausted, retryWithException will not be retried.
*/
@Test(groups = { "unit" }, timeOut = TIMEOUT)
public void shouldRetryWithRetryWithException() {
RxDocumentServiceRequest request = RxDocumentServiceRequest.create(
mockDiagnosticsClientContext(),
OperationType.Read,
ResourceType.Document);
GoneAndRetryWithRetryPolicy goneAndRetryWithRetryPolicy = new GoneAndRetryWithRetryPolicy(request, 1);

ShouldRetryResult shouldRetryResult = Mono.delay(Duration.ofSeconds(1))
.flatMap(t -> goneAndRetryWithRetryPolicy.shouldRetry(new RetryWithException("Test", null, null)))
.block();

assertThat(shouldRetryResult.shouldRetry).isFalse();
assertThat(shouldRetryResult.nonRelatedException).isFalse();
}
}