Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-912

The logic of func DBClientReplicaSet::isFailed() in dbclient_rs.h

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: legacy-1.1.0, legacy-1.1.1
    • Component/s: None

      Hi! I am using DBClientReplicaSet to querying a mongodb replicaset, and I found a bug in this class. In my project, I use client connection as a long keep alive connection. And everytime I reuse this client again, I must check this client whether it is ok. So I use func DBClientReplicaSet::isFailed() to check the client whether it is ok or not. But I found it always return true. I check the code below in dbclient_rs.h

      dbclient_rs.h
          virtual bool isFailed() const {
              return !_master || _master->isFailed();
          }   
      

      In my project, I always query mongodb with the secondary node using the method DBClientReplicaSet::slaveConn(), so the client did not have the chance to init the _master member.
      I think in method isFailed(), not only must we check the _master member, but also the _lastSlaveOkConn member. If one of the two member's status is OK, the method should return true.
      If you think it indeed a bug, I will commit a bug fix later.

      thanks.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            unpeeled_onion@outlook.com ethan zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: