Unreachable code in DataReplicator::_onOplogFetchFinish

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.1.5
    • Affects Version/s: 3.1.4
    • Component/s: Replication
    • Fully Compatible
    • ALL
    • RPL 5 06/26/16
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      DataReplicator::_onOplogFetchFinish has this code:

          BSONElement tsElem(doc->getField("ts"));
          while(tsElem.eoo() || doc != docs.rend()) {
              tsElem =  (doc++)->getField("ts");
          }
      
          if (!tsElem.eoo()) {
              _lastTimestampFetched = tsElem.timestamp();
          } else {
              warning() <<
                      "Did not find a 'ts' timestamp field in any of the fetched documents";
          }
      

      1 - It seems like the while(tsElem.eoo()) condition would prevent the else/warning block from ever being executed because the code can't advance until tsElem.eoo() == false.

      2 - The or condition in while() seems like it could allow doc to advance past docs.rend() when no docs have a 'ts' field. (Should it just be an && condition instead?)

              Assignee:
              Scott Hernandez (Inactive)
              Reporter:
              Kamran K. (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: