Skip to content

Commit 0fc259c

Browse files
CircuitBreaker: Partition availability staleness check background thread should be a daemon thread to not block apps from closing gracefully (#44441)
* CircuitBreaker: Partition availability staleness check background thread should be a daemon thread to not block apps from closing gracefully * Update CHANGELOG.md * Update CosmosSchedulers.java
1 parent 6cfa56d commit 0fc259c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### Breaking Changes
88

99
#### Bugs Fixed
10+
* Fixed applications possibly not closing gracefully due to thread `partition-availability-staleness-check` not being a daemon thread. - [PR 44441](https://github.com/Azure/azure-sdk-for-java/pull/44441).
1011

1112
#### Other Changes
1213

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/CosmosSchedulers.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public class CosmosSchedulers {
5656
Schedulers.DEFAULT_BOUNDED_ELASTIC_SIZE,
5757
Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE,
5858
CLIENT_TELEMETRY_BOUNDED_ELASTIC_THREAD_NAME,
59-
TTL_FOR_SCHEDULER_WORKER_IN_SECONDS
59+
TTL_FOR_SCHEDULER_WORKER_IN_SECONDS,
60+
true
6061
);
6162

6263
// Custom bounded elastic scheduler for open connections

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/circuitBreaker/GlobalPartitionEndpointManagerForCircuitBreaker.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public class GlobalPartitionEndpointManagerForCircuitBreaker implements AutoClos
5151
private final AtomicReference<GlobalAddressResolver> globalAddressResolverSnapshot;
5252
private final ConcurrentHashMap<URI, String> locationToRegion;
5353
private final AtomicBoolean isClosed = new AtomicBoolean(false);
54-
private final Scheduler partitionRecoveryScheduler = Schedulers.newSingle("partition-availability-staleness-check");
54+
private final Scheduler partitionRecoveryScheduler = Schedulers.newSingle(
55+
"partition-availability-staleness-check",
56+
true);
5557

5658
public GlobalPartitionEndpointManagerForCircuitBreaker(GlobalEndpointManager globalEndpointManager) {
5759
this.partitionKeyRangeToLocationSpecificUnavailabilityInfo = new ConcurrentHashMap<>();

0 commit comments

Comments
 (0)