Skip to content

Commit

Permalink
re-enabling oplog first record retrieval hack for backward cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsol committed Oct 11, 2017
1 parent 60d5c24 commit 031488e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/rocks_record_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,13 +1066,12 @@ namespace mongo {
_currentSequenceNumber =
RocksRecoveryUnit::getRocksRecoveryUnit(opCtx)->snapshot()->GetSequenceNumber();

if (!startIterator.isNull() && !_readUntilForOplog.isNull()) {
if (!startIterator.isNull()) {
// This is a hack to speed up first/last record retrieval from the oplog
_oplogHackRestoreBeforeNext = true;
_needFirstSeek = false;
_lastLoc = startIterator;
iterator();
_skipNextAdvance = true;
_eof = false;
restore();
}
}

Expand Down Expand Up @@ -1130,6 +1129,7 @@ namespace mongo {
}

boost::optional<Record> RocksRecordStore::Cursor::next() {
_oplogHackRestoreBeforeNext = false;
if (_eof) {
return {};
}
Expand Down Expand Up @@ -1191,12 +1191,18 @@ namespace mongo {
_currentSequenceNumber = ru->snapshot()->GetSequenceNumber();
}

_skipNextAdvance = false;

if (_eof) return true;
if (_needFirstSeek) return true;
if (_eof || _needFirstSeek) {
_skipNextAdvance = false;
return true;
}

// _skipNextAdvance is reset by positionIterator()
// but in oplog first record retrieval hack case another logic is in use
positionIterator();
if (_oplogHackRestoreBeforeNext) {
_skipNextAdvance = true;
_eof = false;
}
// Return false if the collection is capped and we reached an EOF. Otherwise return true.
return _cappedVisibilityManager && _eof ? false : true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rocks_record_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ namespace mongo {
RecordId _lastLoc;
std::unique_ptr<rocksdb::Iterator> _iterator;
std::string _seekExactResult;
// true between oplog first record retrieval hack start and first next() call
bool _oplogHackRestoreBeforeNext = false;
void positionIterator();
rocksdb::Iterator* iterator();
};
Expand Down

0 comments on commit 031488e

Please sign in to comment.