Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1867

MongoDatabase.runCommand should never fail server selection with a direct connection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.3, 3.1.0
    • Affects Version/s: 3.0.2
    • Component/s: Command Operations
    • Labels:
      None

      Currently the MongoDatabase.runCommand variant that does not take a read preference attempts to select a server that can accept writes (standalone, replica set primary, mongos). But this rules out certain use cases: for example, it will not allow a client to sent a replSetInitiate command to an uninitiated replica set member.

      The correct behavior is to allow the command to be sent to a server that is directly connected to using the single ServerAddress MongoClient constructor.

      A workaround until this is fixed is to use the runCommand variant that accepts a read preference:

      database.runCommand(init, ReadPreference.primary());
      

      Thanks to Jeffrey Phillips Freeman for reporting this in https://groups.google.com/forum/#!topic/mongodb-user/Cy8o4iHG6CU.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: