KV Txn call may deadlock
Opened this issue · 3 comments
Missing CAF here:
https://github.com/PlayFab/consuldotnet/blob/master/Consul/KV.cs#L614
Causes deadlock when the call is made in a Sync context (i.e. caller blocks with GetAwaiter().GetResult()
)
I have the same issue when running integration tests concurrently. Multiple threads try to get keys using GetAwaiter().GetResult() and deadlock occurs.
Use Task.Run() and then get Task.Result, this works correctly.
True, but this isn't ideal - Using Task.Run
, we're just releasing the current thread & offloading the work onto a threadpool thread instead. Ideally, we want the async call: await req.Execute(ct)
to return execution without having to synchronize to the original context (via configureAwait(false)
) so that we can 'sync over async' in our calling code if needed.
It seems this does happen here:
https://github.com/PlayFab/consuldotnet/blob/master/Consul/KV.cs#L409
I'm guessing, the missing CAF on the awaitable in Txn()
is not intended