Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-1209

is_replica_set() should return false when connected to RS primary in standalone mode

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.5.3
    • Affects Version/s: 1.5.0
    • Component/s: None
    • None

      While updating the test suite for compatibility with server version 4.0.0-rc5, I noticed that some tests were failing because I was using the default MONGODB_URI environment variable, which was connecting to "mongodb://127.0.0.1/". That mongod was actually a replica set primary and because the the is_replica_set() function only checks the topology type of the node, it returned true; however, the absence of both replicaSet and multiple nodes in the connection string meant that libmongoc was operating in single-server mode and it did not evaluate any read preferences. This lead to failures in the following two tests:

      • tests/manager/manager-executeCommand-002.phpt
      • tests/manager/manager-executeCommand-003.phpt

      It may be convenient if is_replica_set() was improved to check for either multiple servers or the presence of a replicaSet URI option (by calling get_uri_option()).

      Note: in this case, Manager::getServers() returns an array with a single server. Although the server identifies as a replica set primary (TYPE_RS_PRIMARY) and the secondary is shown in its isMaster output, the topology does not contain any other nodes.

            Assignee:
            derick Derick Rethans
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: