Skip to content

Concurrency error when PreventDisabledFilterConditions is called #174

@prvyk

Description

@prvyk

System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
at
EntityFramework.DynamicFilters.DynamicFilterExtensions.PreventDisabledFilterConditions(DbModelBuilder modelBuilder, String filterName)

Affected software is a ASP.NET Core 3.1 web API using EFv6.44, a restart stopped the error from recurring. I've been using the package for several years (most of the time with .NET Framework) without this issue, this must be a very rare race condition.
I guess the fix is using ConcurrenctDictionary<> Instead of HashSet<>, like the other variables in DynamicFilterExtensions class.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions