Skip to content
Open
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
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#### Breaking Changes

#### Bugs Fixed
* Fixed transient `410/1002` (`PartitionKeyRangeGone`) errors surfacing to callers during a partition split or merge. The `PartitionKeyRangeGoneRetryPolicy` (used on the query and change-feed paths) previously retried only once and ignored the in-progress `410/1007` (`CompletingSplitOrMerge`) and `410/1008` (`CompletingPartitionMigration`) sub-status codes; it now refreshes the routing map and retries those sub-statuses up to 10 times before surfacing the error.

#### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.time.Duration;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

// TODO: this need testing
/**
Expand All @@ -25,7 +26,8 @@ public class PartitionKeyRangeGoneRetryPolicy extends DocumentClientRetryPolicy
private final IPartitionKeyRangeCache partitionKeyRangeCache;
private final String collectionLink;
private final Map<String, Object> requestOptionProperties;
private volatile boolean retried;
private static final int MAX_RETRY_COUNT = 10;
private final AtomicInteger retryCount = new AtomicInteger(0);
Comment on lines +29 to +30
private RxDocumentServiceRequest request;

public PartitionKeyRangeGoneRetryPolicy(DiagnosticsClientContext diagnosticsClientContext,
Expand Down Expand Up @@ -53,9 +55,11 @@ public Mono<ShouldRetryResult> shouldRetry(Exception exception) {
CosmosException clientException = Utils.as(exception, CosmosException.class);
if (clientException != null &&
Exceptions.isStatusCode(clientException, HttpConstants.StatusCodes.GONE) &&
Exceptions.isSubStatusCode(clientException, HttpConstants.SubStatusCodes.PARTITION_KEY_RANGE_GONE)) {
(Exceptions.isSubStatusCode(clientException, HttpConstants.SubStatusCodes.PARTITION_KEY_RANGE_GONE)
|| Exceptions.isSubStatusCode(clientException, HttpConstants.SubStatusCodes.COMPLETING_SPLIT_OR_MERGE)
|| Exceptions.isSubStatusCode(clientException, HttpConstants.SubStatusCodes.COMPLETING_PARTITION_MIGRATION))) {

if (this.retried){
if (this.retryCount.getAndIncrement() >= MAX_RETRY_COUNT) {
return Mono.just(ShouldRetryResult.error(clientException));
}

Expand Down Expand Up @@ -96,10 +100,8 @@ public Mono<ShouldRetryResult> shouldRetry(Exception exception) {
});

// TODO: Check if this behavior can be replaced by doOnSubscribe
return refreshedRoutingMapObs.flatMap(rm -> {
this.retried = true;
return Mono.just(ShouldRetryResult.retryAfter(Duration.ZERO));
});
return refreshedRoutingMapObs.flatMap(rm ->
Mono.just(ShouldRetryResult.retryAfter(Duration.ZERO)));
Comment on lines +103 to +104

});

Expand Down
Loading