diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-09-26 14:02:49 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-10-06 17:30:12 -0400 |
commit | 101e026f45dea5e9e68520238495c89a476e6172 (patch) | |
tree | bbdd3710ffc5721527ad9f5682ef0dbb4876dfee /src/mongo/tools/shim.cpp | |
parent | 10c86dc6cad9853514148e0ab59894a0d29353b9 (diff) | |
download | mongo-101e026f45dea5e9e68520238495c89a476e6172.tar.gz |
SERVER-14668/SERVER-15294 Collection-level locking for all read paths
Diffstat (limited to 'src/mongo/tools/shim.cpp')
-rw-r--r-- | src/mongo/tools/shim.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/tools/shim.cpp b/src/mongo/tools/shim.cpp index 5da90bfd7ae..2badc79261c 100644 --- a/src/mongo/tools/shim.cpp +++ b/src/mongo/tools/shim.cpp @@ -43,7 +43,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/database_holder.h" -#include "mongo/db/client.h" #include "mongo/db/json.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage/record_store.h" @@ -237,12 +236,16 @@ public: virtual void generateOutputDocuments(std::ostream* out) const { invariant(out); toolInfoLog() << "going to try to recover data from: " << _ns << std::endl; + OperationContextImpl txn; - Client::WriteContext cx(&txn, toolGlobalParams.db); - Database* db = dbHolder().get(&txn, toolGlobalParams.db); - Collection* collection = db->getCollection(&txn, _ns); + Database* db = dbHolder().openDb(&txn, toolGlobalParams.db); + if (!db) { + toolError() << "Database does not exist: " << toolGlobalParams.db << std::endl; + return; + } + Collection* collection = db->getCollection(&txn, _ns); if (!collection) { toolError() << "Collection does not exist: " << toolGlobalParams.coll << std::endl; return; @@ -251,6 +254,8 @@ public: toolInfoLog() << "nrecords: " << collection->numRecords(&txn) << " datasize: " << collection->dataSize(&txn); try { + WriteUnitOfWork wunit(&txn); + boost::scoped_ptr<RecordIterator> iter( collection->getRecordStore()->getIteratorForRepair(&txn)); for (DiskLoc currLoc = iter->getNext(); !currLoc.isNull(); currLoc = iter->getNext()) { @@ -287,11 +292,12 @@ public: } } } + + wunit.commit(); } catch (DBException& e) { toolError() << "ERROR recovering: " << _ns << " " << e.toString(); } - cx.commit(); } private: |