A recent change (inf to 14 days) has introduce a deadlock issue when using the driver in a WepAPI project.
Tested on version master (commit fd5d79c5351e56847ed5d82eed946db609ccdb88)
Steps to reproduce (A sample project is attached)
- Create a Web api project (.NET 4.5.1)
- Add C# driver from GitHub
- Use the legacy MongoServer class to get database and collection reference.
public ValuesController()
{
this.client = new MongoClient(serverUrl);
this.server = this.client.GetServer();
this.database = this.server.GetDatabase(databaseName);
this.collection = this.database.GetCollection<MyResource>("Resources");
}
- In a WebApi controller, add a call to FindAll (for example) in an async method
public async Task<IEnumerable<Resource>> Get()
{
return await Task.FromResult(this.collection.FindAll());
}
- Run web site and call twice the same resources. The second call will stay block in
public static TResult Execute<TResult>(this IReadOperation<TResult> operation, IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken))
{
var awaiter = operation.ExecuteAsync(binding, cancellationToken).GetAwaiter();
return awaiter.GetResult();
}
The new High level API work fine