DbContext: Possible race condition affecting DbContext pooling #7251
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
The original PR to have ASP.NET Core benchmarks use explicitly compiled queries (aspnet/Benchmarks@cd24604) contained a bug in the use of
Attach()
inLoadMultipleUpdatesRows()
: if the random number generator returns duplicate IDs in the same run thenAttach()
will fail.@mikeharder pointed out that the expected probability of picking a random number twice or more from a range of 1 to 1001 in 20 attempts should be around 2% but we were seeing around 75% of requests fail.
Switching off
DbContext
pooling (originally introduced to the benchmarks in aspnet/Benchmarks#154) brings the failure rate to expected values.The current theory is that somehow the state of
DbContext
instances is not always correctly reset.The text was updated successfully, but these errors were encountered: