Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

KV Txn call may deadlock #123

Open
danielglennross opened this issue Aug 28, 2018 · 3 comments
Open

KV Txn call may deadlock #123

danielglennross opened this issue Aug 28, 2018 · 3 comments

Comments

@danielglennross
Copy link

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())

@sharkadi-a
Copy link

I have the same issue when running integration tests concurrently. Multiple threads try to get keys using GetAwaiter().GetResult() and deadlock occurs.

@sharkadi-a
Copy link

Use Task.Run() and then get Task.Result, this works correctly.

@danielglennross
Copy link
Author

danielglennross commented Jan 18, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants