MongoServer.Primary is not thread-safe when using a replicaset

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Critical - P2
    • 1.8.2
    • Affects Version/s: 1.8.1
    • Component/s: None
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      System.InvalidOperationException: Sequence contains more than one matching element
      at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
      at MongoDB.Driver.MongoServer.get_Primary()

      MongoServerInstance.Primary is calling _serverProxy.Instances.SingleOrDefault(x => x.IsPrimary);

      In our case proxy is ReplicaSetMongoServerProxy

      When method ProcessConnectedInstanceStateChange is called, the previously disconnected instance can come with Primary set to true.
      In this case the previous Primary instance may not see its flag unset by ProcessConnectedPrimaryStateChange method before a call to MongoServerInstance.Primary is done => Exception.

            Assignee:
            Robert Stam
            Reporter:
            Arnaud TAMAILLON
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: