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

Driver does not automatically reconnect to secondary

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8
    • Affects Version/s: 1.7
    • Component/s: None
    • Labels:
      None
    • Environment:
      Replica set
      Two mongod instances (one with two votes)

      Under the following conditions the client is unable to automatically re-connect to a secondary without restarting IIS:

      • The primary is down
      • The client is connected to the secondary
      • The secondary goes down
      • The secondary comes back up

      In an attempt to recover from this I tried .Reconnect(), but the client is still unable to reconnect to the server.

      Dug into the code a bit and it appears that as soon as the secondary starts up again and the client notices and apparently erroneously removes the secondary from the list of instances. Because the primary is down and the primary is now the only remaining instance the client knows about it will not reconnect.

      If I alter IsValidInstance in ReplicaSetMongoServerProxy to skip the 'instance.InstanceType != MongoServerInstanceType.ReplicaSetMember' check it appears to behave as expected.

      I've tried lots of different connection strings and they do not appear to alter the behavior. Here in an example if it is helpful: mongodb://user:password@localhost,tools/DatabaseName?safe=true&readPreference=primaryPreferred

      I don't understand what should be going on well enough to submit a patch - sorry.

      Thanks,
      -Michael

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            michaelcrino Michael Crino
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: