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.
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.