From 4bddf05750f314faff2bca07bf94021164ee0c3e Mon Sep 17 00:00:00 2001 From: "Arooshi Avasthy (from Dev Box)" Date: Mon, 7 Apr 2025 21:18:25 -0700 Subject: [PATCH 1/2] Fix config refresh and gateway mode check. --- Microsoft.Azure.Cosmos/src/DocumentClient.cs | 10 +++++----- .../src/Routing/GlobalEndpointManager.cs | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 460be822da..63b1c46466 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -1100,11 +1100,7 @@ private async Task GetInitializationTaskAsync(IStoreClientFactory storeCli gatewayStoreModel.SetCaches(this.partitionKeyRangeCache, this.collectionCache); - if (this.ConnectionPolicy.ConnectionMode == ConnectionMode.Gateway) - { - this.StoreModel = this.GatewayStoreModel; - } - else if (this.isThinClientEnabled) + if (this.isThinClientEnabled) { ThinClientStoreModel thinClientStoreModel = new ( endpointManager: this.GlobalEndpointManager, @@ -1118,6 +1114,10 @@ private async Task GetInitializationTaskAsync(IStoreClientFactory storeCli thinClientStoreModel.SetCaches(this.partitionKeyRangeCache, this.collectionCache); this.StoreModel = thinClientStoreModel; + } + else if (this.ConnectionPolicy.ConnectionMode == ConnectionMode.Gateway) + { + this.StoreModel = this.GatewayStoreModel; } else { diff --git a/Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs b/Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs index 4d7884ec58..00670beafd 100644 --- a/Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs +++ b/Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs @@ -554,6 +554,7 @@ public virtual void InitializeAccountPropertiesAndStartBackgroundRefresh(Account { return; } + GlobalEndpointManager.ParseThinClientLocationsFromAdditionalProperties(databaseAccount); this.locationCache.OnDatabaseAccountRead(databaseAccount); From ebd017a9e6e97748aa8dc203bf7b009c93c3b495 Mon Sep 17 00:00:00 2001 From: Arooshi Avasthy Date: Tue, 8 Apr 2025 08:14:59 -0700 Subject: [PATCH 2/2] Update isthinclient enabled check with gateway mode. --- Microsoft.Azure.Cosmos/src/DocumentClient.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 63b1c46466..7772dcd5a1 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -1098,9 +1098,9 @@ private async Task GetInitializationTaskAsync(IStoreClientFactory storeCli this.partitionKeyRangeCache = new PartitionKeyRangeCache(this, this.GatewayStoreModel, this.collectionCache, this.GlobalEndpointManager, this.enableAsyncCacheExceptionNoSharing); this.ResetSessionTokenRetryPolicy = new ResetSessionTokenRetryPolicyFactory(this.sessionContainer, this.collectionCache, this.retryPolicy); - gatewayStoreModel.SetCaches(this.partitionKeyRangeCache, this.collectionCache); - - if (this.isThinClientEnabled) + gatewayStoreModel.SetCaches(this.partitionKeyRangeCache, this.collectionCache); + + if (this.ConnectionPolicy.ConnectionMode == ConnectionMode.Gateway && this.isThinClientEnabled) { ThinClientStoreModel thinClientStoreModel = new ( endpointManager: this.GlobalEndpointManager,