correctly rollback a failed index create

This commit is contained in:
Dwight
2009-10-05 10:19:51 -04:00
parent ff458d03b7
commit 151d960765
2 changed files with 8 additions and 2 deletions

View File

@@ -598,7 +598,7 @@ namespace mongo {
// delete just one index
int x = d->findIndexByName(name);
if ( x >= 0 ) {
out() << " d->nIndexes was " << d->nIndexes << endl;
log(4) << " d->nIndexes was " << d->nIndexes << endl;
anObjBuilder.append("nIndexesWas", (double)d->nIndexes);
/* note it is important we remove the IndexDetails with this

View File

@@ -628,7 +628,13 @@ assert( !eloc.isNull() );
b.append("ns", parentNS().c_str());
BSONObj cond = b.done(); // e.g.: { name: "ts_1", ns: "foo.coll" }
btreeStore->drop(ns.c_str());
/* important to catch exception here so we can finish cleanup below. */
try {
btreeStore->drop(ns.c_str());
}
catch(DBException& ) {
log(2) << "IndexDetails::kill(): couldn't drop ns " << ns << endl;
}
head.setInvalid();
info.setInvalid();