GatewayAddressCache: Fixes Unobserved Exception During Background Address Refresh (#4039)

* Code changes to fix unobserved exception during background address refresh.

* Code changes to add exception handler in task.

* Code changes to fix null ref exception.

* Revert "Code changes to fix null ref exception."

This reverts commit 83f90d578b.

* Revert "Code changes to add exception handler in task."

This reverts commit c49ed81627.

* Code changes to address review comments.

* Revert "Code changes to address review comments."

This reverts commit d2b9f6b501.
This commit is contained in:
Debdatta Kunda 2023-08-16 16:24:03 -07:00 коммит произвёл GitHub
Родитель 946dd4a95f
Коммит 48af69ecab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -302,14 +302,27 @@ namespace Microsoft.Azure.Cosmos.Routing
.ReplicaTransportAddressUris
.Any(x => x.ShouldRefreshHealthStatus()))
{
Task refreshAddressesInBackgroundTask = Task.Run(async () => await this.serverPartitionAddressCache.RefreshAsync(
key: partitionKeyRangeIdentity,
singleValueInitFunc: (currentCachedValue) => this.GetAddressesForRangeIdAsync(
request,
cachedAddresses: currentCachedValue,
Task refreshAddressesInBackgroundTask = Task.Run(async () =>
{
try
{
await this.serverPartitionAddressCache.RefreshAsync(
key: partitionKeyRangeIdentity,
singleValueInitFunc: (currentCachedValue) => this.GetAddressesForRangeIdAsync(
request,
cachedAddresses: currentCachedValue,
partitionKeyRangeIdentity.CollectionRid,
partitionKeyRangeIdentity.PartitionKeyRangeId,
forceRefresh: true));
}
catch (Exception ex)
{
DefaultTrace.TraceWarning("Failed to refresh addresses in the background for the collection rid: {0} with exception: {1}. '{2}'",
partitionKeyRangeIdentity.CollectionRid,
partitionKeyRangeIdentity.PartitionKeyRangeId,
forceRefresh: true)));
ex,
System.Diagnostics.Trace.CorrelationManager.ActivityId);
}
});
}
return addresses;