[SERVER-18903] Unreachable code in DataReplicator::_onOplogFetchFinish Created: 09/Jun/15  Updated: 05/Feb/16  Resolved: 11/Jun/15

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 3.1.4
Fix Version/s: 3.1.5

Type: Bug Priority: Major - P3
Reporter: Kamran K. Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: 32qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-18039 Add Initial Sync Skeleton to DataRepl... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: RPL 5 06/26/16
Participants:

 Description   

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?)



 Comments   
Comment by Githook User [ 11/Jun/15 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-18903: change or to and for iteration
Branch: master
https://github.com/mongodb/mongo/commit/bc208ec615dfda588bb401f2e8e047003ada0c01

Comment by Scott Hernandez (Inactive) [ 10/Jun/15 ]

Yes, should be &&.

Generated at Thu Feb 08 03:49:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.