Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1133

Deadlock in mongo db C# drivers when using legacy MongoServer and WebApi

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
    • Environment:
      Tested under Windows 8.1 x64 / IISExpress / VS 2013 Up 4 / VS 2015 Preview.
    • Sprint:
      C# Sprint 12

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            craiggwilson Craig Wilson
            Reporter:
            phenixdotnet Vincent Lainé
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: