summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/auth/auth_index_d.cpp10
-rw-r--r--src/mongo/db/catalog/collection.cpp14
-rw-r--r--src/mongo/db/catalog/database.cpp4
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp108
-rw-r--r--src/mongo/db/catalog/index_catalog.h42
-rw-r--r--src/mongo/db/catalog/index_create.cpp35
-rw-r--r--src/mongo/db/catalog/index_create.h5
-rw-r--r--src/mongo/db/cloner.cpp4
-rw-r--r--src/mongo/db/commands/create_indexes.cpp2
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp11
-rw-r--r--src/mongo/db/commands/mr.cpp4
-rw-r--r--src/mongo/db/commands/rename_collection.cpp2
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp2
-rw-r--r--src/mongo/db/dbhelpers.cpp2
-rw-r--r--src/mongo/db/index_builder.cpp5
-rw-r--r--src/mongo/db/index_rebuilder.cpp11
-rw-r--r--src/mongo/db/instance.cpp2
-rw-r--r--src/mongo/db/pdfile.cpp7
-rw-r--r--src/mongo/db/repl/oplog.cpp4
-rw-r--r--src/mongo/db/structure/collection_compact.cpp2
-rw-r--r--src/mongo/dbtests/counttests.cpp2
-rw-r--r--src/mongo/dbtests/indexcatalogtests.cpp5
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp16
-rw-r--r--src/mongo/dbtests/oplogstarttests.cpp2
-rw-r--r--src/mongo/dbtests/querytests.cpp2
-rw-r--r--src/mongo/dbtests/repltests.cpp2
-rw-r--r--src/mongo/s/d_migrate.cpp2
27 files changed, 170 insertions, 137 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp
index 738e8883f0e..09c289b70c7 100644
--- a/src/mongo/db/auth/auth_index_d.cpp
+++ b/src/mongo/db/auth/auth_index_d.cpp
@@ -32,12 +32,13 @@
#include "mongo/base/status.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_manager_global.h"
+#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/catalog/collection.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
@@ -83,6 +84,7 @@ namespace {
// Make sure the old unique index from v2.4 on system.users doesn't exist.
Client::WriteContext wctx(systemUsers);
+ DurTransaction txn;
Collection* collection = wctx.ctx().db()->getCollection(NamespaceString(systemUsers));
if (!collection) {
return;
@@ -90,7 +92,7 @@ namespace {
IndexCatalog* indexCatalog = collection->getIndexCatalog();
IndexDescriptor* oldIndex = NULL;
while ((oldIndex = indexCatalog->findIndexByKeyPattern(v1SystemUsersKeyPattern))) {
- indexCatalog->dropIndex(oldIndex);
+ indexCatalog->dropIndex(&txn, oldIndex);
}
}
}
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index b45aa1b0597..eb03c9274bf 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -103,7 +103,7 @@ namespace mongo {
_ns.coll() == "system.indexes" ) );
}
_magic = 1357924;
- _indexCatalog.init();
+ _indexCatalog.init(txn);
}
Collection::~Collection() {
@@ -251,7 +251,7 @@ namespace mongo {
_infoCache.notifyOfWriteOp();
try {
- _indexCatalog.indexRecord( docToInsert, loc.getValue() );
+ _indexCatalog.indexRecord(txn, docToInsert, loc.getValue());
}
catch ( AssertionException& e ) {
if ( _details->isCapped() ) {
@@ -293,7 +293,7 @@ namespace mongo {
/* check if any cursors point to us. if so, advance them. */
_cursorCache.invalidateDocument(loc, INVALIDATION_DELETION);
- _indexCatalog.unindexRecord( doc, loc, noWarn);
+ _indexCatalog.unindexRecord(txn, doc, loc, noWarn);
_recordStore->deleteRecord( txn, loc );
@@ -365,7 +365,7 @@ namespace mongo {
// unindex old record, don't delete
// this way, if inserting new doc fails, we can re-index this one
_cursorCache.invalidateDocument(oldLocation, INVALIDATION_DELETION);
- _indexCatalog.unindexRecord( objOld, oldLocation, true );
+ _indexCatalog.unindexRecord(txn, objOld, oldLocation, true);
if ( debug ) {
if (debug->nmoved == -1) // default of -1 rather than 0
@@ -383,7 +383,7 @@ namespace mongo {
}
else {
// new doc insert failed, so lets re-index the old document and location
- _indexCatalog.indexRecord( objOld, oldLocation );
+ _indexCatalog.indexRecord(txn, objOld, oldLocation);
}
return loc;
@@ -531,7 +531,7 @@ namespace mongo {
}
// 2) drop indexes
- Status status = _indexCatalog.dropAllIndexes( true );
+ Status status = _indexCatalog.dropAllIndexes(txn, true);
if ( !status.isOK() )
return status;
_cursorCache.invalidateAll( false );
@@ -544,7 +544,7 @@ namespace mongo {
// 4) re-create indexes
for ( size_t i = 0; i < indexSpecs.size(); i++ ) {
- status = _indexCatalog.createIndex( indexSpecs[i], false );
+ status = _indexCatalog.createIndex(txn, indexSpecs[i], false);
if ( !status.isOK() )
return status;
}
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index 24678b84a8a..239ae391672 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -405,7 +405,7 @@ namespace mongo {
audit::logDropCollection( currentClient.get(), fullns );
try {
- Status s = collection->getIndexCatalog()->dropAllIndexes( true );
+ Status s = collection->getIndexCatalog()->dropAllIndexes(txn, true);
if ( !s.isOK() ) {
warning() << "could not drop collection, trying to drop indexes"
<< fullns << " because of " << s.toString();
@@ -759,7 +759,7 @@ namespace mongo {
if ( collection->requiresIdIndex() ) {
if ( options.autoIndexId == CollectionOptions::YES ||
options.autoIndexId == CollectionOptions::DEFAULT ) {
- uassertStatusOK( collection->getIndexCatalog()->ensureHaveIdIndex() );
+ uassertStatusOK( collection->getIndexCatalog()->ensureHaveIdIndex(txn) );
}
}
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 70103890a05..47ea2b82e11 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -61,7 +61,7 @@
#include "mongo/db/repl/rs.h" // this is ugly
#include "mongo/db/storage/data_file.h"
#include "mongo/db/storage/extent_manager.h"
-#include "mongo/db/storage/mmap_v1/dur_transaction.h"
+#include "mongo/db/storage/transaction.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/db/structure/catalog/namespace_details_rsv1_metadata.h"
#include "mongo/db/structure/record_store_v1_simple.h"
@@ -92,7 +92,7 @@ namespace mongo {
_magic = 123456;
}
- Status IndexCatalog::init() {
+ Status IndexCatalog::init(TransactionExperiment* txn) {
NamespaceDetails::IndexIterator ii = _details->ii(true);
while ( ii.more() ) {
@@ -109,7 +109,7 @@ namespace mongo {
IndexDescriptor* descriptor = new IndexDescriptor( _collection,
_getAccessMethodName(keyPattern),
ownedInfoObj );
- IndexCatalogEntry* entry = _setupInMemoryStructures( descriptor );
+ IndexCatalogEntry* entry = _setupInMemoryStructures(txn, descriptor );
fassert( 17340, entry->isReady() );
}
@@ -125,8 +125,8 @@ namespace mongo {
return Status::OK();
}
- IndexCatalogEntry* IndexCatalog::_setupInMemoryStructures( IndexDescriptor* descriptor ) {
- DurTransaction txn; //XXX
+ IndexCatalogEntry* IndexCatalog::_setupInMemoryStructures(TransactionExperiment* txn,
+ IndexDescriptor* descriptor) {
auto_ptr<IndexDescriptor> descriptorCleanup( descriptor );
NamespaceDetails* indexMetadata =
@@ -136,7 +136,7 @@ namespace mongo {
str::stream() << "no NamespaceDetails for index: " << descriptor->toString(),
indexMetadata );
- auto_ptr<RecordStore> recordStore( new SimpleRecordStoreV1( &txn,
+ auto_ptr<RecordStore> recordStore( new SimpleRecordStoreV1( txn,
descriptor->indexNamespace(),
new NamespaceDetailsRSV1MetaData( indexMetadata ),
_collection->getExtentManager(),
@@ -166,7 +166,7 @@ namespace mongo {
requirePowerOf2 = true;
if ( requirePowerOf2 ) {
- _collection->setUserFlag(&txn, NamespaceDetails::Flag_UsePowerOf2Sizes);
+ _collection->setUserFlag(txn, NamespaceDetails::Flag_UsePowerOf2Sizes);
}
}
@@ -306,10 +306,12 @@ namespace mongo {
return StatusWith<BSONObj>( fixed );
}
- Status IndexCatalog::createIndex( BSONObj spec,
+ Status IndexCatalog::createIndex( TransactionExperiment* txn,
+ BSONObj spec,
bool mayInterrupt,
ShutdownBehavior shutdownBehavior ) {
Lock::assertWriteLocked( _collection->_database->name() );
+
_checkMagic();
Status status = _checkUnfinished();
if ( !status.isOK() )
@@ -329,7 +331,7 @@ namespace mongo {
}
// now going to touch disk
- IndexBuildBlock indexBuildBlock( _collection, spec );
+ IndexBuildBlock indexBuildBlock(txn, _collection, spec);
status = indexBuildBlock.init();
if ( !status.isOK() )
return status;
@@ -354,7 +356,7 @@ namespace mongo {
// IndexCatalog can be dropped, which means both the Collection and IndexCatalog
// can be destructed out from under us. The runner used by the index build will
// throw a particular exception when it detects that this occurred.
- buildAnIndex( _collection, entry, mayInterrupt );
+ buildAnIndex( txn, _collection, entry, mayInterrupt );
indexBuildBlock.success();
InProgressIndexesMap::iterator it = _inProgressIndexes.find(descriptor);
@@ -395,14 +397,16 @@ namespace mongo {
}
}
- IndexCatalog::IndexBuildBlock::IndexBuildBlock( Collection* collection,
- const BSONObj& spec )
+ IndexCatalog::IndexBuildBlock::IndexBuildBlock(TransactionExperiment* txn,
+ Collection* collection,
+ const BSONObj& spec )
: _collection( collection ),
_catalog( collection->getIndexCatalog() ),
_ns( _catalog->_collection->ns().ns() ),
_spec( spec.getOwned() ),
_entry( NULL ),
- _inProgress( false ) {
+ _inProgress( false ),
+ _txn(txn) {
invariant( collection );
}
@@ -430,8 +434,7 @@ namespace mongo {
Collection* systemIndexes = db->getOrCreateCollection( db->_indexesName );
invariant( systemIndexes );
- DurTransaction txn; //XXX
- StatusWith<DiskLoc> systemIndexesEntry = systemIndexes->insertDocument( &txn, _spec, false );
+ StatusWith<DiskLoc> systemIndexesEntry = systemIndexes->insertDocument( _txn, _spec, false );
if ( !systemIndexesEntry.isOK() )
return systemIndexesEntry.getStatus();
@@ -444,7 +447,7 @@ namespace mongo {
}
catch ( DBException& e ) {
log() << "got exception trying to assign loc to IndexDetails" << e;
- _catalog->_removeFromSystemIndexes( descriptor->indexName() );
+ _catalog->_removeFromSystemIndexes(_txn, descriptor->indexName());
return Status( ErrorCodes::InternalError, e.toString() );
}
@@ -455,7 +458,7 @@ namespace mongo {
catch ( DBException& e ) {
log() << "got exception trying to incrementStats _indexBuildsInProgress: " << e;
fassert( 17344, before == _collection->details()->_indexBuildsInProgress );
- _catalog->_removeFromSystemIndexes( descriptor->indexName() );
+ _catalog->_removeFromSystemIndexes(_txn, descriptor->indexName());
return Status( ErrorCodes::InternalError, e.toString() );
}
@@ -469,11 +472,11 @@ namespace mongo {
nsi.add_ns( descriptor->indexNamespace(), DiskLoc(), false );
// 4) system.namespaces entry index ns
- db->_addNamespaceToCatalog( &txn, descriptor->indexNamespace(), NULL );
+ db->_addNamespaceToCatalog(_txn, descriptor->indexNamespace(), NULL);
/// ---------- setup in memory structures ----------------
- _entry = _catalog->_setupInMemoryStructures( descriptorCleaner.release() );
+ _entry = _catalog->_setupInMemoryStructures(_txn, descriptorCleaner.release());
return Status::OK();
}
@@ -515,10 +518,11 @@ namespace mongo {
invariant( entry == _entry );
if ( entry ) {
- _catalog->_dropIndex( entry );
+ _catalog->_dropIndex(_txn, entry);
}
else {
- _catalog->_deleteIndexFromDisk( _indexName,
+ _catalog->_deleteIndexFromDisk( _txn,
+ _indexName,
_indexNamespace,
idxNo );
}
@@ -709,7 +713,7 @@ namespace mongo {
return Status::OK();
}
- Status IndexCatalog::ensureHaveIdIndex() {
+ Status IndexCatalog::ensureHaveIdIndex(TransactionExperiment* txn) {
if ( _details->isSystemFlagSet( NamespaceDetails::Flag_HaveIdIndex ) )
return Status::OK();
@@ -721,7 +725,7 @@ namespace mongo {
b.append( "key", _idObj );
BSONObj o = b.done();
- Status s = createIndex( o, false );
+ Status s = createIndex(txn, o, false);
if ( s.isOK() || s.code() == ErrorCodes::IndexAlreadyExists ) {
_details->setSystemFlag( NamespaceDetails::Flag_HaveIdIndex );
return Status::OK();
@@ -730,7 +734,9 @@ namespace mongo {
return s;
}
- Status IndexCatalog::dropAllIndexes( bool includingIdIndex ) {
+ Status IndexCatalog::dropAllIndexes(TransactionExperiment* txn,
+ bool includingIdIndex) {
+
Lock::assertWriteLocked( _collection->_database->name() );
BackgroundOperation::assertNoBgOpInProgForNs( _collection->ns().ns() );
@@ -769,7 +775,7 @@ namespace mongo {
LOG(1) << "\t dropAllIndexes dropping: " << desc->toString();
IndexCatalogEntry* entry = _entries.find( desc );
invariant( entry );
- _dropIndex( entry );
+ _dropIndex(txn, entry);
}
// verify state is sane post cleaning
@@ -812,17 +818,23 @@ namespace mongo {
return Status::OK();
}
- Status IndexCatalog::dropIndex( IndexDescriptor* desc ) {
+ Status IndexCatalog::dropIndex(TransactionExperiment* txn,
+ IndexDescriptor* desc ) {
+
Lock::assertWriteLocked( _collection->_database->name() );
IndexCatalogEntry* entry = _entries.find( desc );
+
if ( !entry )
return Status( ErrorCodes::InternalError, "cannot find index to delete" );
+
if ( !entry->isReady() )
return Status( ErrorCodes::InternalError, "cannot delete not ready index" );
- return _dropIndex( entry );
+
+ return _dropIndex(txn, entry);
}
- Status IndexCatalog::_dropIndex( IndexCatalogEntry* entry ) {
+ Status IndexCatalog::_dropIndex(TransactionExperiment* txn,
+ IndexCatalogEntry* entry ) {
/**
* IndexState in order
* <db>.system.indexes
@@ -864,7 +876,8 @@ namespace mongo {
_details->clearSystemFlag( NamespaceDetails::Flag_HaveIdIndex );
// **** this is the first disk change ****
- _deleteIndexFromDisk( indexName,
+ _deleteIndexFromDisk( txn,
+ indexName,
indexNamespace,
idxNo );
}
@@ -888,15 +901,15 @@ namespace mongo {
return Status::OK();
}
- void IndexCatalog::_deleteIndexFromDisk( const string& indexName,
+ void IndexCatalog::_deleteIndexFromDisk( TransactionExperiment* txn,
+ const string& indexName,
const string& indexNamespace,
int idxNo ) {
invariant( idxNo >= 0 );
invariant(_details->_catalogFindIndexByName(_collection, indexName, true) == idxNo);
// data + system.namespacesa
- DurTransaction txn; // XXX
- Status status = _collection->_database->_dropNS( &txn, indexNamespace );
+ Status status = _collection->_database->_dropNS( txn, indexNamespace );
if ( status.code() == ErrorCodes::NamespaceNotFound ) {
// this is ok, as we may be partially through index creation
}
@@ -910,17 +923,17 @@ namespace mongo {
// remove from system.indexes
// n is how many things were removed from this
// probably should clean this up
- int n = _removeFromSystemIndexes( indexName );
+ int n = _removeFromSystemIndexes(txn, indexName);
wassert( n == 1 );
}
- int IndexCatalog::_removeFromSystemIndexes( const StringData& indexName ) {
+ int IndexCatalog::_removeFromSystemIndexes(TransactionExperiment* txn,
+ const StringData& indexName) {
BSONObjBuilder b;
b.append( "ns", _collection->ns() );
b.append( "name", indexName );
BSONObj cond = b.obj(); // e.g.: { name: "ts_1", ns: "foo.coll" }
- DurTransaction txn; // XXX
- return static_cast<int>( deleteObjects( &txn,
+ return static_cast<int>( deleteObjects( txn,
_collection->_database->_indexesName,
cond,
false,
@@ -928,7 +941,7 @@ namespace mongo {
true ) );
}
- vector<BSONObj> IndexCatalog::getAndClearUnfinishedIndexes() {
+ vector<BSONObj> IndexCatalog::getAndClearUnfinishedIndexes(TransactionExperiment* txn) {
vector<BSONObj> toReturn = _unfinishedIndexes;
_unfinishedIndexes.clear();
for ( size_t i = 0; i < toReturn.size(); i++ ) {
@@ -941,7 +954,8 @@ namespace mongo {
invariant( idxNo >= 0 );
invariant( idxNo >= numIndexesReady() );
- _deleteIndexFromDisk( desc.indexName(),
+ _deleteIndexFromDisk( txn,
+ desc.indexName(),
desc.indexNamespace(),
idxNo );
}
@@ -1198,8 +1212,9 @@ namespace mongo {
}
- void IndexCatalog::indexRecord( const BSONObj& obj, const DiskLoc &loc ) {
- DurTransaction txn; // XXX
+ void IndexCatalog::indexRecord(TransactionExperiment* txn,
+ const BSONObj& obj,
+ const DiskLoc &loc ) {
for ( IndexCatalogEntryContainer::const_iterator i = _entries.begin();
i != _entries.end();
@@ -1208,7 +1223,7 @@ namespace mongo {
IndexCatalogEntry* entry = *i;
try {
- Status s = _indexRecord( &txn, entry, obj, loc );
+ Status s = _indexRecord( txn, entry, obj, loc );
uassert(s.location(), s.reason(), s.isOK() );
}
catch ( AssertionException& ae ) {
@@ -1222,7 +1237,7 @@ namespace mongo {
IndexCatalogEntry* toDelete = *j;
try {
- _unindexRecord(&txn, toDelete, obj, loc, false);
+ _unindexRecord(txn, toDelete, obj, loc, false);
}
catch ( DBException& e ) {
LOG(1) << "IndexCatalog::indexRecord rollback failed: " << e;
@@ -1238,8 +1253,10 @@ namespace mongo {
}
- void IndexCatalog::unindexRecord( const BSONObj& obj, const DiskLoc& loc, bool noWarn ) {
- DurTransaction txn; // XXX
+ void IndexCatalog::unindexRecord(TransactionExperiment* txn,
+ const BSONObj& obj,
+ const DiskLoc& loc,
+ bool noWarn) {
for ( IndexCatalogEntryContainer::const_iterator i = _entries.begin();
i != _entries.end();
@@ -1249,9 +1266,8 @@ namespace mongo {
// If it's a background index, we DO NOT want to log anything.
bool logIfError = entry->isReady() ? !noWarn : false;
- _unindexRecord(&txn, entry, obj, loc, logIfError);
+ _unindexRecord(txn, entry, obj, loc, logIfError);
}
-
}
Status IndexCatalog::checkNoIndexConflicts( const BSONObj &obj ) {
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index a90fb689475..7646cbd53f1 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -61,7 +61,7 @@ namespace mongo {
~IndexCatalog();
// must be called before used
- Status init();
+ Status init(TransactionExperiment* txn);
bool ok() const;
@@ -139,28 +139,31 @@ namespace mongo {
// ---- index set modifiers ------
- Status ensureHaveIdIndex();
+ Status ensureHaveIdIndex(TransactionExperiment* txn);
enum ShutdownBehavior {
SHUTDOWN_CLEANUP, // fully clean up this build
SHUTDOWN_LEAVE_DIRTY // leave as if kill -9 happened, so have to deal with on restart
};
- Status createIndex( BSONObj spec,
+ Status createIndex( TransactionExperiment* txn,
+ BSONObj spec,
bool mayInterrupt,
ShutdownBehavior shutdownBehavior = SHUTDOWN_CLEANUP );
StatusWith<BSONObj> prepareSpecForCreate( const BSONObj& original ) const;
- Status dropAllIndexes( bool includingIdIndex );
+ Status dropAllIndexes(TransactionExperiment* txn,
+ bool includingIdIndex );
- Status dropIndex( IndexDescriptor* desc );
+ Status dropIndex(TransactionExperiment* txn,
+ IndexDescriptor* desc );
/**
* will drop all incompleted indexes and return specs
* after this, the indexes can be rebuilt
*/
- vector<BSONObj> getAndClearUnfinishedIndexes();
+ vector<BSONObj> getAndClearUnfinishedIndexes(TransactionExperiment* txn);
struct IndexKillCriteria {
@@ -200,8 +203,10 @@ namespace mongo {
*/
class IndexBuildBlock {
public:
- IndexBuildBlock( Collection* collection,
- const BSONObj& spec );
+ IndexBuildBlock(TransactionExperiment* txn,
+ Collection* collection,
+ const BSONObj& spec );
+
~IndexBuildBlock();
Status init();
@@ -234,14 +239,19 @@ namespace mongo {
IndexCatalogEntry* _entry;
bool _inProgress;
+
+ TransactionExperiment* _txn;
};
// ----- data modifiers ------
// this throws for now
- void indexRecord( const BSONObj& obj, const DiskLoc &loc );
+ void indexRecord(TransactionExperiment* txn, const BSONObj& obj, const DiskLoc &loc);
- void unindexRecord( const BSONObj& obj, const DiskLoc& loc, bool noWarn );
+ void unindexRecord(TransactionExperiment* txn,
+ const BSONObj& obj,
+ const DiskLoc& loc,
+ bool noWarn);
/**
* checks all unique indexes and checks for conflicts
@@ -268,7 +278,8 @@ namespace mongo {
IndexAccessMethod* _createAccessMethod( const IndexDescriptor* desc,
IndexCatalogEntry* entry );
- int _removeFromSystemIndexes( const StringData& indexName );
+ int _removeFromSystemIndexes(TransactionExperiment* txn,
+ const StringData& indexName );
bool _shouldOverridePlugin( const BSONObj& keyPattern ) const;
@@ -302,16 +313,19 @@ namespace mongo {
/**
* this does no sanity checks
*/
- Status _dropIndex( IndexCatalogEntry* entry );
+ Status _dropIndex(TransactionExperiment* txn,
+ IndexCatalogEntry* entry );
// just does disk hanges
// doesn't change memory state, etc...
- void _deleteIndexFromDisk( const string& indexName,
+ void _deleteIndexFromDisk( TransactionExperiment* txn,
+ const string& indexName,
const string& indexNamespace,
int idxNo );
// descriptor ownership passes to _setupInMemoryStructures
- IndexCatalogEntry* _setupInMemoryStructures( IndexDescriptor* descriptor );
+ IndexCatalogEntry* _setupInMemoryStructures(TransactionExperiment* txn,
+ IndexDescriptor* descriptor );
static BSONObj _fixIndexSpec( const BSONObj& spec );
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
index 0b488e469c1..29fcef4dead 100644
--- a/src/mongo/db/catalog/index_create.cpp
+++ b/src/mongo/db/catalog/index_create.cpp
@@ -45,7 +45,7 @@
#include "mongo/db/repl/is_master.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/rs.h"
-#include "mongo/db/storage/mmap_v1/dur_transaction.h"
+#include "mongo/db/storage/transaction.h"
#include "mongo/db/structure/catalog/index_details.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/util/processinfo.h"
@@ -77,13 +77,12 @@ namespace mongo {
uassertStatusOK( ret );
}
- unsigned long long addExistingToIndex( Collection* collection,
+ unsigned long long addExistingToIndex( TransactionExperiment* txn,
+ Collection* collection,
const IndexDescriptor* descriptor,
IndexAccessMethod* accessMethod,
bool shouldYield) {
- DurTransaction txn; // XXX
-
string ns = collection->ns().ns(); // our copy for sanity
bool dupsAllowed = !descriptor->unique();
@@ -124,10 +123,10 @@ namespace mongo {
try {
if ( !dupsAllowed && dropDups ) {
LastError::Disabled led( lastError.get() );
- addKeysToIndex(&txn, collection, descriptor, accessMethod, js, loc);
+ addKeysToIndex(txn, collection, descriptor, accessMethod, js, loc);
}
else {
- addKeysToIndex(&txn, collection, descriptor, accessMethod, js, loc);
+ addKeysToIndex(txn, collection, descriptor, accessMethod, js, loc);
}
}
catch( AssertionException& e ) {
@@ -140,8 +139,8 @@ namespace mongo {
bool runnerEOF = runner->isEOF();
runner->saveState();
BSONObj toDelete;
- collection->deleteDocument( &txn, loc, false, true, &toDelete );
- logOp( &txn, "d", ns.c_str(), toDelete );
+ collection->deleteDocument( txn, loc, false, true, &toDelete );
+ logOp( txn, "d", ns.c_str(), toDelete );
if (!runner->restoreState()) {
// Runner got killed somehow. This probably shouldn't happen.
@@ -200,7 +199,8 @@ namespace mongo {
// ---------------------------
// throws DBException
- void buildAnIndex( Collection* collection,
+ void buildAnIndex( TransactionExperiment* txn,
+ Collection* collection,
IndexCatalogEntry* btreeState,
bool mayInterrupt ) {
@@ -219,10 +219,8 @@ namespace mongo {
// things like in place updates, etc...
collection->infoCache()->addedIndex();
- DurTransaction txn; // XXX
-
if ( collection->numRecords() == 0 ) {
- Status status = btreeState->accessMethod()->initializeAsEmpty(&txn);
+ Status status = btreeState->accessMethod()->initializeAsEmpty(txn);
massert( 17343,
str::stream() << "IndexAccessMethod::initializeAsEmpty failed" << status.toString(),
status.isOK() );
@@ -242,21 +240,22 @@ namespace mongo {
log() << "\t building index in background";
}
- Status status = btreeState->accessMethod()->initializeAsEmpty(&txn);
+ Status status = btreeState->accessMethod()->initializeAsEmpty(txn);
massert( 17342,
str::stream()
<< "IndexAccessMethod::initializeAsEmpty failed"
<< status.toString(),
status.isOK() );
- IndexAccessMethod* bulk = doInBackground ? NULL : btreeState->accessMethod()->initiateBulk(&txn);
+ IndexAccessMethod* bulk = doInBackground ? NULL : btreeState->accessMethod()->initiateBulk(txn);
scoped_ptr<IndexAccessMethod> bulkHolder(bulk);
IndexAccessMethod* iam = bulk ? bulk : btreeState->accessMethod();
if ( bulk )
log() << "\t building index using bulk method";
- unsigned long long n = addExistingToIndex( collection,
+ unsigned long long n = addExistingToIndex( txn,
+ collection,
btreeState->descriptor(),
iam,
doInBackground );
@@ -284,13 +283,13 @@ namespace mongo {
for( set<DiskLoc>::const_iterator i = dupsToDrop.begin(); i != dupsToDrop.end(); ++i ) {
BSONObj toDelete;
- collection->deleteDocument( &txn,
+ collection->deleteDocument( txn,
*i,
false /* cappedOk */,
true /* noWarn */,
&toDelete );
if ( isMaster( ns.c_str() ) ) {
- logOp( &txn, "d", ns.c_str(), toDelete );
+ logOp( txn, "d", ns.c_str(), toDelete );
}
getDur().commitIfNeeded();
@@ -346,7 +345,7 @@ namespace mongo {
info = statusWithInfo.getValue();
IndexState state;
- state.block = new IndexCatalog::IndexBuildBlock( _collection, info );
+ state.block = new IndexCatalog::IndexBuildBlock(_txn, _collection, info);
status = state.block->init();
if ( !status.isOK() )
return status;
diff --git a/src/mongo/db/catalog/index_create.h b/src/mongo/db/catalog/index_create.h
index 1484c06df59..bc2681465d8 100644
--- a/src/mongo/db/catalog/index_create.h
+++ b/src/mongo/db/catalog/index_create.h
@@ -37,18 +37,19 @@
#include "mongo/base/status.h"
#include "mongo/db/diskloc.h"
#include "mongo/db/index/index_access_method.h"
-#include "mongo/db/storage/transaction.h"
namespace mongo {
class BSONObj;
class Collection;
class IndexCatalogEntry;
+ class TransactionExperiment;
// Build an index in the foreground
// If background is false, uses fast index builder
// If background is true, uses background index builder; blocks until done.
- void buildAnIndex( Collection* collection,
+ void buildAnIndex( TransactionExperiment* txn,
+ Collection* collection,
IndexCatalogEntry* btreeState,
bool mayInterrupt );
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 11e6f7394c3..6e2fd3bec3e 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -268,7 +268,7 @@ namespace mongo {
verify( collection );
}
- Status status = collection->getIndexCatalog()->createIndex( spec, mayBeInterrupted );
+ Status status = collection->getIndexCatalog()->createIndex(txn, spec, mayBeInterrupted);
if ( status.code() == ErrorCodes::IndexAlreadyExists ) {
// no-op
}
@@ -511,7 +511,7 @@ namespace mongo {
inDBRepair = true;
Collection* c = context.db()->getCollection( to_name );
if ( c )
- c->getIndexCatalog()->ensureHaveIdIndex();
+ c->getIndexCatalog()->ensureHaveIdIndex(txn);
inDBRepair = old;
}
catch(...) {
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index ae1a67705bb..ddc9fa9b535 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -191,7 +191,7 @@ namespace mongo {
}
}
- status = collection->getIndexCatalog()->createIndex( spec, true );
+ status = collection->getIndexCatalog()->createIndex(&txn, spec, true);
if ( status.code() == ErrorCodes::IndexAlreadyExists ) {
if ( !result.hasField( "note" ) )
result.append( "note", "index already exists" );
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 4be07264893..f7655fdbcb3 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -132,7 +132,7 @@ namespace mongo {
string indexToDelete = f.valuestr();
if ( indexToDelete == "*" ) {
- Status s = indexCatalog->dropAllIndexes( false );
+ Status s = indexCatalog->dropAllIndexes(txn, false);
if ( !s.isOK() ) {
appendCommandStatus( anObjBuilder, s );
return false;
@@ -152,7 +152,7 @@ namespace mongo {
return false;
}
- Status s = indexCatalog->dropIndex( desc );
+ Status s = indexCatalog->dropIndex(txn, desc);
if ( !s.isOK() ) {
appendCommandStatus( anObjBuilder, s );
return false;
@@ -174,7 +174,7 @@ namespace mongo {
return false;
}
- Status s = indexCatalog->dropIndex( desc );
+ Status s = indexCatalog->dropIndex(txn, desc);
if ( !s.isOK() ) {
appendCommandStatus( anObjBuilder, s );
return false;
@@ -223,6 +223,7 @@ namespace mongo {
Lock::DBWrite dbXLock(dbname);
Client::Context ctx(toDeleteNs);
+ DurTransaction txn;
Collection* collection = ctx.db()->getCollection( toDeleteNs );
@@ -254,7 +255,7 @@ namespace mongo {
}
result.appendNumber( "nIndexesWas", collection->getIndexCatalog()->numIndexesTotal() );
- Status s = collection->getIndexCatalog()->dropAllIndexes( true );
+ Status s = collection->getIndexCatalog()->dropAllIndexes(&txn, true);
if ( !s.isOK() ) {
errmsg = "dropIndexes failed";
return appendCommandStatus( result, s );
@@ -263,7 +264,7 @@ namespace mongo {
for ( list<BSONObj>::iterator i=all.begin(); i!=all.end(); i++ ) {
BSONObj o = *i;
LOG(1) << "reIndex ns: " << toDeleteNs << " index: " << o << endl;
- Status s = collection->getIndexCatalog()->createIndex( o, false );
+ Status s = collection->getIndexCatalog()->createIndex(&txn, o, false);
if ( !s.isOK() )
return appendCommandStatus( result, s );
}
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 8ef751e2384..63fd17c5e14 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -359,7 +359,7 @@ namespace mongo {
BSONObj indexSpec = BSON( "key" << BSON( "0" << 1 ) << "ns" << _config.incLong
<< "name" << "_temp_0" );
- Status status = incColl->getIndexCatalog()->createIndex( indexSpec, false );
+ Status status = incColl->getIndexCatalog()->createIndex(&txn, indexSpec, false);
// Log the createIndex operation.
string logNs = nsToDatabase( _config.incLong ) + ".system.indexes";
logOp( &txn, "i", logNs.c_str(), indexSpec );
@@ -419,7 +419,7 @@ namespace mongo {
for ( vector<BSONObj>::iterator it = indexesToInsert.begin();
it != indexesToInsert.end(); ++it ) {
- tempColl->getIndexCatalog()->createIndex( *it, false );
+ tempColl->getIndexCatalog()->createIndex(&txn, *it, false );
// Log the createIndex operation.
string logNs = nsToDatabase( _config.tempNamespace ) + ".system.indexes";
logOp( &txn, "i", logNs.c_str(), *it );
diff --git a/src/mongo/db/commands/rename_collection.cpp b/src/mongo/db/commands/rename_collection.cpp
index e7b2def57af..3fb948d2b6e 100644
--- a/src/mongo/db/commands/rename_collection.cpp
+++ b/src/mongo/db/commands/rename_collection.cpp
@@ -318,7 +318,7 @@ namespace mongo {
for ( vector<BSONObj>::iterator it = copiedIndexes.begin();
it != copiedIndexes.end(); ++it ) {
- Status s = targetColl->getIndexCatalog()->createIndex( *it, true );
+ Status s = targetColl->getIndexCatalog()->createIndex(txn, *it, true );
if ( !s.isOK() ) {
indexSuccessful = false;
errmsg = s.toString();
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 8e4acb7f00a..b4940b0ccba 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -1044,7 +1044,7 @@ namespace mongo {
Lock::assertWriteLocked( indexNS );
- Status status = collection->getIndexCatalog()->createIndex( indexDesc, true );
+ Status status = collection->getIndexCatalog()->createIndex(&txn, indexDesc, true);
if ( status.code() == ErrorCodes::IndexAlreadyExists ) {
result->getStats().n = 0;
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 9517636e004..1f5381fe45c 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -72,7 +72,7 @@ namespace mongo {
b.appendBool("unique", unique);
BSONObj o = b.done();
- Status status = collection->getIndexCatalog()->createIndex( o, false );
+ Status status = collection->getIndexCatalog()->createIndex(txn, o, false);
if ( status.code() == ErrorCodes::IndexAlreadyExists )
return;
uassertStatusOK( status );
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 92b4c404150..0a0a808fd90 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/d_concurrency.h"
#include "mongo/db/repl/rs.h"
+#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -82,7 +83,9 @@ namespace mongo {
// Show which index we're building in the curop display.
context.getClient()->curop()->setQuery(_index);
- Status status = c->getIndexCatalog()->createIndex( _index,
+ DurTransaction txn; // XXX
+ Status status = c->getIndexCatalog()->createIndex( &txn,
+ _index,
true,
IndexCatalog::SHUTDOWN_LEAVE_DIRTY );
if ( status.code() == ErrorCodes::IndexAlreadyExists )
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index 35969190807..fddb9f59ccb 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -30,12 +30,13 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/user_name.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/client.h"
#include "mongo/db/instance.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/repl/rs.h"
-#include "mongo/db/catalog/collection.h"
+#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
@@ -89,6 +90,8 @@ namespace mongo {
// This write lock is held throughout the index building process
// for this namespace.
Client::WriteContext ctx(ns);
+ DurTransaction txn; // XXX???
+
Collection* collection = ctx.ctx().db()->getCollection( ns );
if ( collection == NULL )
continue;
@@ -97,11 +100,11 @@ namespace mongo {
if ( collection->ns().isOplog() && indexCatalog->numIndexesTotal() > 0 ) {
warning() << ns << " had illegal indexes, removing";
- indexCatalog->dropAllIndexes( true );
+ indexCatalog->dropAllIndexes(&txn, true);
continue;
}
- vector<BSONObj> indexesToBuild = indexCatalog->getAndClearUnfinishedIndexes();
+ vector<BSONObj> indexesToBuild = indexCatalog->getAndClearUnfinishedIndexes(&txn);
// The indexes have now been removed from system.indexes, so the only record is
// in-memory. If there is a journal commit between now and when insert() rewrites
@@ -132,7 +135,7 @@ namespace mongo {
log() << "going to rebuild: " << indexObj;
- Status status = indexCatalog->createIndex( indexObj, false );
+ Status status = indexCatalog->createIndex(&txn, indexObj, false);
if ( !status.isOK() ) {
log() << "building index failed: " << status.toString() << " index: " << indexObj;
}
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index f46f749cd9b..2efe48f1160 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -818,7 +818,7 @@ namespace mongo {
bool mayInterrupt = cc().curop()->parent() == NULL;
cc().curop()->setQuery(js);
- Status status = collection->getIndexCatalog()->createIndex( js, mayInterrupt );
+ Status status = collection->getIndexCatalog()->createIndex(txn, js, mayInterrupt);
if ( status.code() == ErrorCodes::IndexAlreadyExists )
return;
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index 02e8dfbddf5..b7b0e1b9e65 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -92,13 +92,6 @@ namespace mongo {
return _dbHolder;
}
- void ensureIdIndexForNewNs( Collection* collection ) {
- if ( collection->ns().isSystem() && !legalClientSystemNS( collection->ns().ns(), false ) )
- return;
-
- uassertStatusOK( collection->getIndexCatalog()->ensureHaveIdIndex() );
- }
-
/*---------------------------------------------------------------------*/
/** { ..., capped: true, size: ..., max: ... }
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index e828b46056c..405b21c45aa 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -600,7 +600,7 @@ namespace mongo {
// probably don't need this since all replicated colls have _id indexes now
// but keep it just in case
RARELY if ( indexCatalog && !collection->isCapped() ) {
- indexCatalog->ensureHaveIdIndex();
+ indexCatalog->ensureHaveIdIndex(txn);
}
/* todo : it may be better to do an insert here, and then catch the dup key exception and do update
@@ -629,7 +629,7 @@ namespace mongo {
// probably don't need this since all replicated colls have _id indexes now
// but keep it just in case
RARELY if ( indexCatalog && !collection->isCapped() ) {
- indexCatalog->ensureHaveIdIndex();
+ indexCatalog->ensureHaveIdIndex(txn);
}
OpDebug debug;
diff --git a/src/mongo/db/structure/collection_compact.cpp b/src/mongo/db/structure/collection_compact.cpp
index 793cfd5d096..86b75523859 100644
--- a/src/mongo/db/structure/collection_compact.cpp
+++ b/src/mongo/db/structure/collection_compact.cpp
@@ -143,7 +143,7 @@ namespace mongo {
// note that the drop indexes call also invalidates all clientcursors for the namespace,
// which is important and wanted here
log() << "compact dropping indexes" << endl;
- Status status = _indexCatalog.dropAllIndexes( true );
+ Status status = _indexCatalog.dropAllIndexes(txn, true);
if ( !status.isOK() ) {
return StatusWith<CompactStats>( status );
}
diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp
index 103eb50e503..c69efefbe11 100644
--- a/src/mongo/dbtests/counttests.cpp
+++ b/src/mongo/dbtests/counttests.cpp
@@ -75,7 +75,7 @@ namespace CountTests {
b.append( "ns", ns() );
b.append( "key", key );
BSONObj o = b.done();
- Status s = _collection->getIndexCatalog()->createIndex( o, false );
+ Status s = _collection->getIndexCatalog()->createIndex(&_txn, o, false);
uassertStatusOK( s );
}
void insert( const char *s ) {
diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp
index 71ad6be6197..982edf5c8a9 100644
--- a/src/mongo/dbtests/indexcatalogtests.cpp
+++ b/src/mongo/dbtests/indexcatalogtests.cpp
@@ -46,19 +46,20 @@ namespace IndexCatalogTests {
void run() {
Client::WriteContext ctx(_ns);
+ DurTransaction txn;
int numFinishedIndexesStart = _catalog->numIndexesReady();
BSONObjBuilder b1;
b1.append("key", BSON("x" << 1));
b1.append("ns", _ns);
b1.append("name", "_x_0");
- _catalog->createIndex(b1.obj(), true);
+ _catalog->createIndex(&txn, b1.obj(), true);
BSONObjBuilder b2;
b2.append("key", BSON("y" << 1));
b2.append("ns", _ns);
b2.append("name", "_y_0");
- _catalog->createIndex(b2.obj(), true);
+ _catalog->createIndex(&txn, b2.obj(), true);
ASSERT_TRUE(_catalog->numIndexesReady() == numFinishedIndexesStart+2);
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 5cff0a5b1ac..64a80338f4f 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -318,7 +318,7 @@ namespace IndexUpdateTests {
db->dropCollection( &_txn, _ns );
Collection* coll = db->createCollection( &_txn, _ns );
// Drop all indexes including id index.
- coll->getIndexCatalog()->dropAllIndexes( true );
+ coll->getIndexCatalog()->dropAllIndexes(&_txn, true );
// Insert some documents with enforceQuota=true.
int32_t nDocs = 1000;
for( int32_t i = 0; i < nDocs; ++i ) {
@@ -330,7 +330,7 @@ namespace IndexUpdateTests {
killCurrentOp.killAll();
BSONObj indexInfo = BSON( "key" << BSON( "a" << 1 ) << "ns" << _ns << "name" << "a_1" );
// The call is interrupted because mayInterrupt == true.
- Status status = coll->getIndexCatalog()->createIndex( indexInfo, true );
+ Status status = coll->getIndexCatalog()->createIndex(&_txn, indexInfo, true );
ASSERT_NOT_OK( status.code() );
// only want to interrupt the index build
killCurrentOp.reset();
@@ -347,7 +347,7 @@ namespace IndexUpdateTests {
Database* db = _ctx.ctx().db();
db->dropCollection( &_txn, _ns );
Collection* coll = db->createCollection( &_txn, _ns );
- coll->getIndexCatalog()->dropAllIndexes( true );
+ coll->getIndexCatalog()->dropAllIndexes(&_txn, true );
// Insert some documents.
int32_t nDocs = 1000;
for( int32_t i = 0; i < nDocs; ++i ) {
@@ -359,7 +359,7 @@ namespace IndexUpdateTests {
killCurrentOp.killAll();
BSONObj indexInfo = BSON( "key" << BSON( "a" << 1 ) << "ns" << _ns << "name" << "a_1" );
// The call is not interrupted because mayInterrupt == false.
- Status status = coll->getIndexCatalog()->createIndex( indexInfo, false );
+ Status status = coll->getIndexCatalog()->createIndex(&_txn, indexInfo, false );
ASSERT_OK( status.code() );
// only want to interrupt the index build
killCurrentOp.reset();
@@ -379,7 +379,7 @@ namespace IndexUpdateTests {
options.capped = true;
options.cappedSize = 10 * 1024;
Collection* coll = db->createCollection( &_txn, _ns, options );
- coll->getIndexCatalog()->dropAllIndexes( true );
+ coll->getIndexCatalog()->dropAllIndexes(&_txn, true );
// Insert some documents.
int32_t nDocs = 1000;
for( int32_t i = 0; i < nDocs; ++i ) {
@@ -393,7 +393,7 @@ namespace IndexUpdateTests {
"ns" << _ns <<
"name" << "_id_" );
// The call is interrupted because mayInterrupt == true.
- Status status = coll->getIndexCatalog()->createIndex( indexInfo, true );
+ Status status = coll->getIndexCatalog()->createIndex(&_txn, indexInfo, true );
ASSERT_NOT_OK( status.code() );
// only want to interrupt the index build
killCurrentOp.reset();
@@ -413,7 +413,7 @@ namespace IndexUpdateTests {
options.capped = true;
options.cappedSize = 10 * 1024;
Collection* coll = db->createCollection( &_txn, _ns, options );
- coll->getIndexCatalog()->dropAllIndexes( true );
+ coll->getIndexCatalog()->dropAllIndexes(&_txn, true );
// Insert some documents.
int32_t nDocs = 1000;
for( int32_t i = 0; i < nDocs; ++i ) {
@@ -427,7 +427,7 @@ namespace IndexUpdateTests {
"ns" << _ns <<
"name" << "_id_" );
// The call is not interrupted because mayInterrupt == false.
- Status status = coll->getIndexCatalog()->createIndex( indexInfo, false );
+ Status status = coll->getIndexCatalog()->createIndex(&_txn, indexInfo, false );
ASSERT_OK( status.code() );
// only want to interrupt the index build
killCurrentOp.reset();
diff --git a/src/mongo/dbtests/oplogstarttests.cpp b/src/mongo/dbtests/oplogstarttests.cpp
index 8e602dfdf70..890430f54da 100644
--- a/src/mongo/dbtests/oplogstarttests.cpp
+++ b/src/mongo/dbtests/oplogstarttests.cpp
@@ -43,7 +43,7 @@ namespace OplogStartTests {
if (!c) {
c = _context.db()->createCollection(&txn, ns());
}
- c->getIndexCatalog()->ensureHaveIdIndex();
+ c->getIndexCatalog()->ensureHaveIdIndex(&txn);
}
~Base() {
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 0fe9362e542..7190885849d 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -86,7 +86,7 @@ namespace QueryTests {
b.append( "ns", ns() );
b.append( "key", key );
BSONObj o = b.done();
- Status s = _collection->getIndexCatalog()->createIndex( o, false );
+ Status s = _collection->getIndexCatalog()->createIndex(&_txn, o, false);
uassertStatusOK( s );
}
void insert( const char *s ) {
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index f5e69b0d81f..64ef01e091a 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -69,7 +69,7 @@ namespace ReplTests {
if ( ! c ) {
c = _context.db()->createCollection( &_txn, ns() );
}
- c->getIndexCatalog()->ensureHaveIdIndex();
+ c->getIndexCatalog()->ensureHaveIdIndex(&_txn);
}
~Base() {
try {
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index d1badf93d33..8aaa7c998b5 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -1668,7 +1668,7 @@ namespace mongo {
return;
}
- Status status = collection->getIndexCatalog()->createIndex( idx, false );
+ Status status = collection->getIndexCatalog()->createIndex(&txn, idx, false);
if ( !status.isOK() && status.code() != ErrorCodes::IndexAlreadyExists ) {
errmsg = str::stream() << "failed to create index before migrating data. "
<< " idx: " << idx