summaryrefslogtreecommitdiff
path: root/src/mongo/db/index_update.cpp
diff options
context:
space:
mode:
authorKristina <kristina@10gen.com>2012-11-12 10:19:43 -0500
committerKristina <kristina@10gen.com>2012-11-12 11:51:01 -0500
commitab1bceba74845666aaad957cab256cadf2a0c8de (patch)
tree54e206b27215cdfd6e9c703b7db563d22ffb92b5 /src/mongo/db/index_update.cpp
parent3abcc53d43145bcda52016c753e10ff139d41e4d (diff)
downloadmongo-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.cpp28
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: */