Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for https://github.com/mongodb-partners/mongo-rocks/issues/108 #111

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/rocks_record_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,10 @@ namespace mongo {

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 @@ -1159,6 +1159,7 @@ namespace mongo {
}

boost::optional<Record> RocksRecordStore::Cursor::seekExact(const RecordId& id) {
_oplogHackRestoreBeforeNext = false;
_needFirstSeek = false;
_skipNextAdvance = false;
_iterator.reset();
Expand Down Expand Up @@ -1191,12 +1192,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
3 changes: 3 additions & 0 deletions src/rocks_record_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ namespace mongo {
RecordId _lastLoc;
std::unique_ptr<rocksdb::Iterator> _iterator;
std::string _seekExactResult;
// true between oplog first record retrieval hack start and first
// positioning call (next(), seekExact())
bool _oplogHackRestoreBeforeNext = false;
void positionIterator();
rocksdb::Iterator* iterator();
};
Expand Down