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

Hang opening new async cursor

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • 2.13.3
    • None
    • None

    Description

      Application Info:

      Target Framework: .NET 6,

      Project Type: Blazor Server Side, Microsoft.NET.Sdk.Web

      Summary

      Similar issue to CSHARP-3477

      When I open an Async Cursor, the application hangs.

      I have determined it is the opening of the cursor, if I use code like this:

      using var cursor = await _collection.FindAsync(query, options, token);
       
      while (await cursor.MoveNextAsync(token))
           loopProcessor(cursor.Current);
      

      If I change the call to be:

      await _collection.FindAsync(query, options, token).ToList();
      

      Everything works as expected.

      All this code is in a repository class that lives in an internally developed library and is used across several applications.  The only application that hangs is the Blazor Server Side app.

      I have not been able to duplicate this issue in any other code.  It happens consistently in the Blazor app always on the same line of code. Here is the code that calls the repository class:

      private List<Product> GetProductData(FilterDefinition<Product> filter)
      {
          IEnumerable<Product>? productList = null;
          IEnumerable<Product>? partialProductList = null;
       
          System.Diagnostics.Debug.WriteLine("Process Id = {0}.", System.Diagnostics.Process.GetCurrentProcess().Id);
       
          var productListTask = _productService.GetItemsFromMongoAsync(filter, new FindOptions<Product, Product>());
          var partialProductListTask = _partialProductService.GetItemsFromMongoAsync(filter, new FindOptions<Product, Product>());
       
          Task.WaitAll(productListTask, partialProductListTask);
       
          if (partialProductListTask.IsCompletedSuccessfully)
              partialProductList = partialProductListTask.Result;
       
          if (productListTask.IsCompletedSuccessfully)
              productList = productListTask.Result;
       
          if (productList is not null && partialProductList is not null)
              return productList.Union(partialProductList).Distinct().OrderBy(a => a.Ean).ToList();
          else if (productList is not null && partialProductList is null)
              return productList.ToList();
          else if (productList is null && partialProductList is not null)
              return partialProductList.ToList();
          return new List<Product>();
      }
      

      I have attached several dump files. The dump file that ends in 095844 is immediately before the call to mongo.  All the other files are after the app has hung.

       

       

      Attachments

        1. dump_20220328_095844.zip
          91.78 MB
        2. dump_20220328_095900.zip
          92.71 MB
        3. dump_20220328_095940.zip
          92.92 MB
        4. dump_20220328_100311.zip
          93.25 MB
        5. dump_20220328_100416.zip
          93.39 MB
        6. dump_20220328_100535.zip
          93.46 MB
        7. dump_20220328_100638.zip
          93.67 MB

        Activity

          People

            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            msimkin@bn.com Marc Simkin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: