summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-03-14 09:32:18 -0400
committerEliot Horowitz <eliot@10gen.com>2014-03-14 09:32:48 -0400
commitfce1d8d0932775d6106e1ca9b17ae7bde15a2c74 (patch)
treebb2d83ea440400f3bef79261faab40713d33846d
parent55a6a0d284e0921a877020592857b3abf6c6cb73 (diff)
downloadmongo-fce1d8d0932775d6106e1ca9b17ae7bde15a2c74.tar.gz
SERVEr-12990: interrupted index after interim succesful index kills correct index
-rw-r--r--src/mongo/db/pdfile.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index 7aaa24a9fbc..aa49b156a28 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -1477,16 +1477,20 @@ namespace mongo {
}
try {
- IndexDetails& idx = tableToIndex->getNextIndexDetails(tabletoidxns.c_str());
- // It's important that this is outside the inner try/catch so that we never try to call
- // kill_idx on a half-formed disk loc (if this asserts).
- getDur().writingDiskLoc(idx.info) = loc;
+ {
+ IndexDetails& idx = tableToIndex->getNextIndexDetails(tabletoidxns.c_str());
+ // It's important that this is outside the inner try/catch so that we never try to call
+ // kill_idx on a half-formed disk loc (if this asserts).
+ getDur().writingDiskLoc(idx.info) = loc;
+ }
try {
+ IndexDetails& idx = tableToIndex->getNextIndexDetails(tabletoidxns.c_str());
getDur().writingInt(tableToIndex->indexBuildsInProgress) += 1;
buildAnIndex(tabletoidxns, tableToIndex, idx, background, mayInterrupt);
}
catch (DBException& e) {
+ log() << "error building index: " << e << endl;
// save our error msg string as an exception or dropIndexes will overwrite our message
LastError *le = lastError.get();
int savecode = 0;
@@ -1501,7 +1505,10 @@ namespace mongo {
}
// Recalculate the index # so we can remove it from the list in the next catch
+
idxNo = IndexBuildsInProgress::get(tabletoidxns.c_str(), idxName);
+ IndexDetails& idx = tableToIndex->idx(idxNo);
+
// roll back this index
idx.kill_idx();
@@ -1521,6 +1528,7 @@ namespace mongo {
<< tableToIndex->nIndexes << endl;
// We cannot use idx here, as it may point to a different index entry if it was
// flipped during building
+
IndexDetails temp = tableToIndex->idx(idxNo);
*getDur().writing(&tableToIndex->idx(idxNo)) =
tableToIndex->idx(tableToIndex->nIndexes);
@@ -1533,6 +1541,7 @@ namespace mongo {
tableToIndex->setIndexIsMultikey(tabletoidxns.c_str(), tableToIndex->nIndexes,
tempMultikey);
+
idxNo = tableToIndex->nIndexes;
}
@@ -1544,10 +1553,10 @@ namespace mongo {
tableToIndex->addIndex(tabletoidxns.c_str());
getDur().writingInt(tableToIndex->indexBuildsInProgress) -= 1;
- IndexType* indexType = idx.getSpec().getType();
+ IndexType* indexType = tableToIndex->idx(idxNo).getSpec().getType();
const IndexPlugin *plugin = indexType ? indexType->getPlugin() : NULL;
if (plugin) {
- plugin->postBuildHook( idx.getSpec() );
+ plugin->postBuildHook( tableToIndex->idx(idxNo).getSpec() );
}
}