diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2018-02-26 16:42:56 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2018-02-26 16:42:56 +1100 |
commit | 35582b7fadbab50130afed7044dc89ab655bae7b (patch) | |
tree | f564c81b1db814a93654dd71778ae5901a9c502a /src/mongo | |
parent | 1e541da1aa391bee43548388c98451df0e54e1c1 (diff) | |
download | mongo-35582b7fadbab50130afed7044dc89ab655bae7b.tar.gz |
SERVER-32533 In oplog truncate with WT, don't use a start key.
Previously there was a performance benefit to tracking the first
expected key in the oplog. The performance issue is no longer
relevant, and supplying a key makes the code fragile (if the tracked
key gets out of sync with the real first key).
(cherry picked from commit f4ac177b55bc762e977dc093a40e442b7061f58c)
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 5c323bc40f9..4d1d0a8faab 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1221,15 +1221,22 @@ void WiredTigerRecordStore::reclaimOplog(OperationContext* txn) { try { WriteUnitOfWork wuow(txn); - WiredTigerCursor startwrap(_uri, _tableId, true, txn); - WT_CURSOR* start = startwrap.get(); - start->set_key(start, _makeKey(_oplogStones->firstRecord)); + WiredTigerCursor cwrap(_uri, _tableId, true, txn); + WT_CURSOR* cursor = cwrap.get(); - WiredTigerCursor endwrap(_uri, _tableId, true, txn); - WT_CURSOR* end = endwrap.get(); - end->set_key(end, _makeKey(stone->lastRecord)); + // The first record in the oplog should be within the truncate range. + int ret = WT_READ_CHECK(cursor->next(cursor)); + invariantWTOK(ret); + int64_t key; + invariantWTOK(cursor->get_key(cursor, &key)); + RecordId firstRecord = _fromKey(key); + if (firstRecord < _oplogStones->firstRecord || firstRecord > stone->lastRecord) { + warning() << "First oplog record " << firstRecord << " is not in truncation range (" + << _oplogStones->firstRecord << ", " << stone->lastRecord << ")"; + } - invariantWTOK(session->truncate(session, nullptr, start, end, nullptr)); + cursor->set_key(cursor, _makeKey(stone->lastRecord)); + invariantWTOK(session->truncate(session, nullptr, nullptr, cursor, nullptr)); _changeNumRecords(txn, -stone->records); _increaseDataSize(txn, -stone->bytes); |