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

Race condition with reusing connections

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.8.3
    • Affects Version/s: 1.8.1
    • Component/s: None
    • None
    • Environment:
      OSX, Mono 3.2.1
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      When executing the code:

      List<TDmo> items = cursor.ToList();

      An error occurs deserializing a document. Code in the finally block of MongoDB.Bson/Serialization/Serializers/BsonClassMapSerializer.cs, DeserializeMemberValue(BsonReader, BsonMemberMap) throws a nice exception.

      Then, while unwinding the stack the finally block in MongoCSharp/MongoDB.Driver/Operations/QueryOperation.cs, Execute(IConnectionProvider) calls KillCursor() which calls AcquireConnection(). This appears to acquire the connection that is in the process of being closed from the exception above.

      If you step through the code in the debugger (MonoDevelop or Xamarin Studio), you slow things down enough so that a FileFormatException is throw. In production, you typically just the InvalidOperationException.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            john@lyon-smith.org John Lyon-Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: