diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-01-27 18:57:31 -0500 |
---|---|---|
committer | Ramon Fernandez <ramon.fernandez@mongodb.com> | 2015-01-27 20:35:01 -0500 |
commit | 9de555036b50926184a9ee707efa29b0dd92d7ff (patch) | |
tree | fd4ad643b50ac0c31a26e8e486006bea3bd25b8f | |
parent | 2bec03aa00484ae15c9729d6611a679f629ae33e (diff) | |
download | mongo-9de555036b50926184a9ee707efa29b0dd92d7ff.tar.gz |
SERVER-17030 More WCE handling for index builds
(cherry picked from commit 9134f4c4f376dc60a389b0d7f385802a49867bbe)
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog.h | 6 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_create.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_access_method.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_bulk_access_method.cpp | 5 |
6 files changed, 13 insertions, 45 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 134aae5e197..3e00ed23121 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -381,16 +381,12 @@ namespace { _ns( _catalog->_collection->ns().ns() ), _spec( spec.getOwned() ), _entry( NULL ), - _inProgress( false ), _txn(txn) { invariant( collection ); } Status IndexCatalog::IndexBuildBlock::init() { - // we do special cleanup until we're far enough in - invariant( _inProgress == false ); - // need this first for names, etc... BSONObj keyPattern = _spec.getObjectField("key"); IndexDescriptor* descriptor = new IndexDescriptor( _collection, @@ -407,10 +403,6 @@ namespace { if ( !status.isOK() ) return status; - // at this point we can do normal clean up procedure, so we mark ourselves - // as in progress. - _inProgress = true; - /// ---------- setup in memory structures ---------------- const bool initFromDisk = false; _entry = _catalog->_setupInMemoryStructures(_txn, @@ -427,8 +419,6 @@ namespace { void IndexCatalog::IndexBuildBlock::fail() { fassert( 17204, _catalog->_collection->ok() ); // defensive - _inProgress = false; - IndexCatalogEntry* entry = _catalog->_entries.find( _indexName ); invariant( entry == _entry ); @@ -442,14 +432,7 @@ namespace { } } - void IndexCatalog::IndexBuildBlock::abortWithoutCleanup() { - _inProgress = false; - } - void IndexCatalog::IndexBuildBlock::success() { - fassert( 17206, _inProgress ); - _inProgress = false; - fassert( 17207, _catalog->_collection->ok() ); _catalog->_collection->getCatalogEntry()->indexBuildSuccess( _txn, _indexName ); diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h index 115dab8a29e..5c74dbf1469 100644 --- a/src/mongo/db/catalog/index_catalog.h +++ b/src/mongo/db/catalog/index_catalog.h @@ -260,12 +260,6 @@ namespace mongo { */ void fail(); - /** - * we're stopping the build - * do NOT cleanup, leave meta data as is - */ - void abortWithoutCleanup(); - IndexCatalogEntry* getEntry() { return _entry; } private: diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp index 60314c24b20..8155258a93c 100644 --- a/src/mongo/db/catalog/index_create.cpp +++ b/src/mongo/db/catalog/index_create.cpp @@ -338,9 +338,6 @@ namespace mongo { } void MultiIndexBlock::abortWithoutCleanup() { - for ( size_t i = 0; i < _indexes.size(); i++ ) { - _indexes[i].block->abortWithoutCleanup(); - } _indexes.clear(); _needToCleanup = false; } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 9de937f6ad7..fa27282f985 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -149,13 +149,16 @@ namespace mongo { Collection* collection = db->getCollection( ns.ns() ); result.appendBool( "createdCollectionAutomatically", collection == NULL ); if ( !collection ) { - WriteUnitOfWork wunit(txn); - collection = db->createCollection( txn, ns.ns() ); - invariant( collection ); - if (!fromRepl) { - repl::logOp(txn, "c", (dbname + ".$cmd").c_str(), BSON("create" << ns.coll())); - } - wunit.commit(); + MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { + WriteUnitOfWork wunit(txn); + collection = db->createCollection( txn, ns.ns() ); + invariant( collection ); + if (!fromRepl) { + repl::logOp(txn, "c", (dbname + ".$cmd").c_str(), + BSON("create" << ns.coll())); + } + wunit.commit(); + } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "createIndexes", ns.ns()); } const int numIndexesBefore = collection->getIndexCatalog()->numIndexesTotal(txn); diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp index e94208462ac..bdab0144628 100644 --- a/src/mongo/db/index/btree_based_access_method.cpp +++ b/src/mongo/db/index/btree_based_access_method.cpp @@ -298,11 +298,6 @@ namespace mongo { } IndexAccessMethod* BtreeBasedAccessMethod::initiateBulk(OperationContext* txn) { - // If there's already data in the index, don't do anything. - if (!_newInterface->isEmpty(txn)) { - return NULL; - } - return new BtreeBasedBulkAccessMethod(txn, this, _newInterface.get(), @@ -315,11 +310,6 @@ namespace mongo { set<RecordId>* dupsToDrop) { BtreeBasedBulkAccessMethod* bulk = static_cast<BtreeBasedBulkAccessMethod*>(bulkRaw); - - if (!_newInterface->isEmpty(bulk->getOperationContext())) { - return Status(ErrorCodes::InternalError, "trying to commit but has data already"); - } - return bulk->commit(dupsToDrop, mayInterrupt, dupsAllowed); } diff --git a/src/mongo/db/index/btree_based_bulk_access_method.cpp b/src/mongo/db/index/btree_based_bulk_access_method.cpp index fa1121ac5e9..8683d88527c 100644 --- a/src/mongo/db/index/btree_based_bulk_access_method.cpp +++ b/src/mongo/db/index/btree_based_bulk_access_method.cpp @@ -34,6 +34,7 @@ #include <boost/scoped_ptr.hpp> +#include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" #include "mongo/db/operation_context.h" #include "mongo/db/storage_options.h" @@ -133,7 +134,7 @@ namespace mongo { scoped_ptr<SortedDataBuilderInterface> builder; - { + MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { WriteUnitOfWork wunit(_txn); if (_isMultiKey) { @@ -142,7 +143,7 @@ namespace mongo { builder.reset(_interface->getBulkBuilder(_txn, dupsAllowed)); wunit.commit(); - } + } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "setting index multikey flag", ""); while (i->more()) { if (mayInterrupt) { |