diff options
author | Eric Milkie <milkie@10gen.com> | 2018-04-26 14:48:49 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2018-04-27 08:43:45 -0400 |
commit | e5552ea011accdab31a4569dd340852580ca7e19 (patch) | |
tree | cb314cbcdcd46835c25cc5640c5b88aa32bb436e | |
parent | e6b5a3c9dcab97bd8a09f6c9cd61fcd34f75d541 (diff) | |
download | mongo-e5552ea011accdab31a4569dd340852580ca7e19.tar.gz |
SERVER-34091 Make sure we read all committed entries when truncating the oplog
This backports commit f5d4aae1587479ff917bd5aa81d2c0decc68a836.
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 9acf1e78193..4d621054bda 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1590,6 +1590,15 @@ void WiredTigerRecordStore::_increaseDataSize(OperationContext* opCtx, int64_t a void WiredTigerRecordStore::cappedTruncateAfter(OperationContext* opCtx, RecordId end, bool inclusive) { + if (_isOplog) { + // If we are truncating the oplog, we want to make sure that a forward cursor reads all + // committed oplog entries. Oplog visibility rules could prevent this if the oplog read + // timestamp has not yet been updated to reflect all committed oplog transactions. Setting + // the read timestamp to its maximum value should ensure that we read the effects of all + // previously committed transactions. + invariant(opCtx->recoveryUnit()->selectSnapshot(Timestamp::max()).isOK()); + } + std::unique_ptr<SeekableRecordCursor> cursor = getCursor(opCtx, true); auto record = cursor->seekExact(end); |