-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: 2.5
-
Component/s: Write Operations
-
Environment:Windows server
1. In one independent thread, context, uses a AsyncHelper.RunSync(...) wrapper invoke mongodb's UpdateOneAsync method.
What "AsyncHelper" does is it replaces the SynchronizationContext.Current with a "ExclusiveSynchronizationContext", and replace back, one finished execution.
2. In another completely independent thread/context, executing following code:
code line 1...
... // SynchronizationContext.Current is null
await mongodb.UpdateOneAsync(); //with, or without .ConfigureAwait(false)
...// SynchronizationContext.Current is "ExclusiveSynchronizationContext"
These 2 calls not related to each other.
This is not 100% time happening. But when happen, it causes deadlock, or potential security issue as it leaks SynchronizationContext.
The code of AsyncHelper is attached.