Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18903

Unreachable code in DataReplicator::_onOplogFetchFinish

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

      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:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: