Skip to content

Commit

Permalink
LocationCache ConcurrentDict lock contention fix (#558)
Browse files Browse the repository at this point in the history
* LocalCache ConcurrentDict lock contention fix

* Documentation included

* Release notes added

* refreshing changelog
  • Loading branch information
kirankumarkolli authored Jul 17, 2019
1 parent f799c18 commit 245e9bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 6 additions & 4 deletions Microsoft.Azure.Cosmos/src/Routing/LocationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public ReadOnlyCollection<Uri> ReadEndpoints
{
get
{
if (this.locationUnavailablityInfoByEndpoint.Count > 0
&& DateTime.UtcNow - this.lastCacheUpdateTimestamp > this.unavailableLocationsExpirationTime)
// Hot-path: avoid ConcurrentDictionary methods which acquire locks
if (DateTime.UtcNow - this.lastCacheUpdateTimestamp > this.unavailableLocationsExpirationTime
&& this.locationUnavailablityInfoByEndpoint.Any())
{
this.UpdateLocationCache();
}
Expand All @@ -98,8 +99,9 @@ public ReadOnlyCollection<Uri> WriteEndpoints
{
get
{
if (this.locationUnavailablityInfoByEndpoint.Count > 0
&& DateTime.UtcNow - this.lastCacheUpdateTimestamp > this.unavailableLocationsExpirationTime)
// Hot-path: avoid ConcurrentDictionary methods which acquire locks
if (DateTime.UtcNow - this.lastCacheUpdateTimestamp > this.unavailableLocationsExpirationTime
&& this.locationUnavailablityInfoByEndpoint.Any())
{
this.UpdateLocationCache();
}
Expand Down
4 changes: 1 addition & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Expand All @@ -14,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- [#548](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/548) Fixed mis-typed message in CosmosException.ToString();
- [#558](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/558) LocationCache ConcurrentDict lock contention fix

## [3.0.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.0.0) - 2019-07-15

Expand Down

0 comments on commit 245e9bb

Please sign in to comment.