Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocationCache ConcurrentDict lock contention fix #558

Merged
merged 6 commits into from
Jul 17, 2019
Merged
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
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())
kirankumarkolli marked this conversation as resolved.
Show resolved Hide resolved
{
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