Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Issue: SqlQuery(sql) with async does not honour ConfigureAwait(false) [1284]

$
0
0
Hi,
The following code in a web application (where there is a synchronization context) causes a dead-lock in EF6-beta1 (this code was working in EF6-alpha3).


public async Task<SequenceBucket> GetNextBucket()
{
var bucket = await this.Database.SqlQuery<Sequence>(GetNextBucketSql).SingleAsync().ConfigureAwait(false); // dead-lock here
...
return new SequenceBucket(bucket);
}

and from another place the caller:

var currentBucket = context.GetNextBucket().Result; // dead-lock here

This should not be causing a deadlock, as the method GetNextBucket is awaiting but passing a ConfigureAwait(false), so even if the call to .Result is blocking the current thread, the sql callback should be coming in a different thread.

If I did not use a stored procedure, and instead called SingleAsync() on a Set<Sequence>() instead of in the SqlQuery<Sequence>(), then the code does not cause a deadlock (as expected).

Also, if I call this from a unit test for example (where there is no sync context, then the test passes without any deadlock.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>