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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Works as Designed
    • Affects Version/s: legacy-1.1.0, legacy-1.1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Sprint:
      Platforms 15 (06/03/16)

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: