diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-11-20 18:48:36 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-11-23 11:11:47 -0500 |
commit | 84ff80c1c6ecd71558419af1f5057d22c93676e9 (patch) | |
tree | 241bb1d7a76dc22a9ce187e0b7c694ad0269a5d0 | |
parent | add4a6c58835fc0b1211bdee118f23741bce4807 (diff) | |
download | mongo-84ff80c1c6ecd71558419af1f5057d22c93676e9.tar.gz |
SERVER-21606 inMemory storage engine should support touch command
5 files changed, 24 insertions, 2 deletions
diff --git a/jstests/concurrency/fsm_workloads/touch_base.js b/jstests/concurrency/fsm_workloads/touch_base.js index 0f8e26976de..df2d0851cd5 100644 --- a/jstests/concurrency/fsm_workloads/touch_base.js +++ b/jstests/concurrency/fsm_workloads/touch_base.js @@ -9,7 +9,8 @@ load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload load('jstests/concurrency/fsm_workloads/indexed_insert_where.js'); // for $config -load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongod and isMMAPv1 +// For isMongod, isMMAPv1, and isEphemeral. +load('jstests/concurrency/fsm_workload_helpers/server_types.js'); var $config = extendWorkload($config, function($config, $super) { $config.data.generateDocumentToInsert = function generateDocumentToInsert() { @@ -22,7 +23,7 @@ var $config = extendWorkload($config, function($config, $super) { $config.states.touch = function touch(db, collName) { var res = db.runCommand(this.generateTouchCmdObj(collName)); - if (isMongod(db) && isMMAPv1(db)) { + if (isMongod(db) && (isMMAPv1(db) || isEphemeral(db))) { assertAlways.commandWorked(res); } else { // SERVER-16850 and SERVER-16797 diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index e9970a867aa..9c51f2cc2a8 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -378,6 +378,15 @@ bool WiredTigerIndex::isEmpty(OperationContext* txn) { return false; } +Status WiredTigerIndex::touch(OperationContext* txn) const { + if (WiredTigerRecoveryUnit::get(txn)->getSessionCache()->isEphemeral()) { + // Everything is already in memory. + return Status::OK(); + } + return Status(ErrorCodes::CommandNotSupported, "this storage engine does not support touch"); +} + + long long WiredTigerIndex::getSpaceUsedBytes(OperationContext* txn) const { WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSession(txn); return static_cast<long long>(WiredTigerUtil::getIdentSize(session->getSession(), _uri)); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h index f59db31411a..4ea5741e7a5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h @@ -100,6 +100,8 @@ public: virtual bool isEmpty(OperationContext* txn); + virtual Status touch(OperationContext* txn) const; + virtual long long getSpaceUsedBytes(OperationContext* txn) const; bool isDup(WT_CURSOR* c, const BSONObj& key, const RecordId& id); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index c8d9f705fa1..7567a37562a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1536,6 +1536,14 @@ void WiredTigerRecordStore::appendCustomStats(OperationContext* txn, } } +Status WiredTigerRecordStore::touch(OperationContext* txn, BSONObjBuilder* output) const { + if (_isEphemeral) { + // Everything is already in memory. + return Status::OK(); + } + return Status(ErrorCodes::CommandNotSupported, "this storage engine does not support touch"); +} + Status WiredTigerRecordStore::oplogDiskLocRegister(OperationContext* txn, const Timestamp& opTime) { StatusWith<RecordId> id = oploghack::keyForOptime(opTime); if (!id.isOK()) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index 669bf5b94e1..dcd30cf77be 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -177,6 +177,8 @@ public: BSONObjBuilder* result, double scale) const; + virtual Status touch(OperationContext* txn, BSONObjBuilder* output) const; + virtual void temp_cappedTruncateAfter(OperationContext* txn, RecordId end, bool inclusive); virtual boost::optional<RecordId> oplogStartHack(OperationContext* txn, |