diff options
author | Kristina <kristina@10gen.com> | 2012-11-12 10:19:43 -0500 |
---|---|---|
committer | Kristina <kristina@10gen.com> | 2012-11-12 11:51:01 -0500 |
commit | ab1bceba74845666aaad957cab256cadf2a0c8de (patch) | |
tree | 54e206b27215cdfd6e9c703b7db563d22ffb92b5 /src/mongo/db/index_update.cpp | |
parent | 3abcc53d43145bcda52016c753e10ff139d41e4d (diff) | |
download | mongo-ab1bceba74845666aaad957cab256cadf2a0c8de.tar.gz |
SERVER-2771 Retry index builds on startup
Diffstat (limited to 'src/mongo/db/index_update.cpp')
-rw-r--r-- | src/mongo/db/index_update.cpp | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/mongo/db/index_update.cpp b/src/mongo/db/index_update.cpp index 0e268b8ce61..107465bf14b 100644 --- a/src/mongo/db/index_update.cpp +++ b/src/mongo/db/index_update.cpp @@ -515,29 +515,6 @@ namespace mongo { } }; - /** - * For the lifetime of this object, an index build is indicated on the specified - * namespace and the newest index is marked as absent. This simplifies - * the cleanup required on recovery. - */ - class RecoverableIndexState { - public: - RecoverableIndexState( NamespaceDetails *d ) : _d( d ) { - indexBuildInProgress() = 1; - nIndexes()--; - } - ~RecoverableIndexState() { - DESTRUCTOR_GUARD ( - nIndexes()++; - indexBuildInProgress() = 0; - ) - } - private: - int &nIndexes() { return getDur().writingInt( _d->nIndexes ); } - int &indexBuildInProgress() { return getDur().writingInt( _d->indexBuildInProgress ); } - NamespaceDetails *_d; - }; - // throws DBException void buildAnIndex(const std::string& ns, NamespaceDetails* d, @@ -550,9 +527,7 @@ namespace mongo { unsigned long long n; verify( !BackgroundOperation::inProgForNs(ns.c_str()) ); // should have been checked earlier, better not be... - verify( d->indexBuildInProgress == 0 ); verify( Lock::isWriteLocked(ns) ); - RecoverableIndexState recoverable( d ); // Build index spec here in case the collection is empty and the index details are invalid idx.getSpec(); @@ -676,7 +651,8 @@ namespace mongo { d->nIndexes = 0; } if ( idIndex ) { - d->addIndex(ns) = *idIndex; + d->getNextIndexDetails(ns) = *idIndex; + d->addIndex(ns); wassert( d->nIndexes == 1 ); } /* assuming here that id index is not multikey: */ |