Closed ColinRaaijmakers closed 6 years ago
Thanks for the report. Added the syncLock
via #https://github.com/VahidN/EFSecondLevelCache.Core/commit/8d5341e739674fdac1bf45f5168be40dda251cdc
Hi guys. Still having issues with same error. Are you sure that we can use lock that easily within async context? I have multiple queries which some use Cacheable() and some not. When i call all this queries in async then i receive above error which comming from Materialize() method where lock resides. @VahidN
But if I remove .cacheable() everything works
I should be able to reproduce it, to debug it. Please provide a basic sample which shows this behavior.
I can bake some code to reproduce latter, but for now you can check this article https://blog.cdemi.io/async-waiting-inside-c-sharp-locks/ Basically you can replace lock with semaphores and everything should work
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.
Summary of the issue
In a multi threaded application i receive random the following error:
System.InvalidOperationException: A second operation started on this context before a previous operation completed. Any instance members are not guaranteed to be thread safe. at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()
Environment
Example code/Steps to reproduce:
Output:
Solution
I have downloaded the source code and added SyncLocks to EFCachedQueryProvider in the Materialize method.
This is working as expected.
How can I commit this change to your project on Github?
Best regards, Colin