From 0a42b54f0e936e72941ce152b52e8d535901ebd8 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 22 Jun 2020 12:31:04 +0200 Subject: [PATCH] Correctly remove locks in query caches Fixes #21245 --- src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs | 2 +- src/EFCore/Query/Internal/CompiledQueryCache.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs index d7c6821e5bd..383e21048ec 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs @@ -97,7 +97,7 @@ public virtual IRelationalCommand GetRelationalCommand([NotNull] IReadOnlyDictio } finally { - _locks.TryRemove(compilationLock, out _); + _locks.TryRemove(cacheKey, out _); } } diff --git a/src/EFCore/Query/Internal/CompiledQueryCache.cs b/src/EFCore/Query/Internal/CompiledQueryCache.cs index 889bfab81ea..0ba038098ee 100644 --- a/src/EFCore/Query/Internal/CompiledQueryCache.cs +++ b/src/EFCore/Query/Internal/CompiledQueryCache.cs @@ -77,7 +77,7 @@ public virtual Func GetOrAddQuery( } finally { - _locks.TryRemove(compilationLock, out _); + _locks.TryRemove(cacheKey, out _); } } }