diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-03-02 17:03:39 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-03-02 17:03:39 -0500 |
commit | 66032f9ec00a0f16cbb2ad0565548c6b1a564099 (patch) | |
tree | 162b2ca371712107d8d41d1093467e62b96eecc0 | |
parent | 221e9a82b87e4f3297b4b057820c90820bf0d009 (diff) | |
download | mongo-66032f9ec00a0f16cbb2ad0565548c6b1a564099.tar.gz |
Revert "SERVER-16348 renameCollection should skip in-progress index builds"
This reverts commit 221e9a82b87e4f3297b4b057820c90820bf0d009.
-rw-r--r-- | src/mongo/db/catalog/database.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index 387bee2a082..c4f4bcd272b 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -515,26 +515,18 @@ namespace mongo { audit::logRenameCollection( currentClient.get(), fromNS, toNS ); // move index namespaces - BSONObj indexSpec; - while (Helpers::findOne(_indexesName, BSON("ns" << fromNS), indexSpec)) { - const BSONObj oldIndexSpec = indexSpec.getOwned(); - int indexI = details->_catalogFindIndexByName(oldIndexSpec.getStringField("name")); - - // Return value of -1 means the index was not found. That can only happen if it is an - // in-progress index. We skip those, because the restart call after rename will kick - // them off again on the new namespace. - if (indexI == -1) { - continue; - } + BSONObj oldIndexSpec; + while( Helpers::findOne( _indexesName, BSON( "ns" << fromNS ), oldIndexSpec ) ) { + oldIndexSpec = oldIndexSpec.getOwned(); BSONObj newIndexSpec; { BSONObjBuilder b; - BSONObjIterator i(oldIndexSpec); - while (i.more()) { + BSONObjIterator i( oldIndexSpec ); + while( i.more() ) { BSONElement e = i.next(); - if (strcmp(e.fieldName(), "ns") != 0) - b.append(e); + if ( strcmp( e.fieldName(), "ns" ) != 0 ) + b.append( e ); else b << "ns" << toNS; } @@ -546,6 +538,7 @@ namespace mongo { if ( !newIndexSpecLoc.isOK() ) return newIndexSpecLoc.getStatus(); + int indexI = details->_catalogFindIndexByName( oldIndexSpec.getStringField( "name" ) ); IndexDetails &indexDetails = details->idx(indexI); string oldIndexNs = indexDetails.indexNamespace(); indexDetails.info = newIndexSpecLoc.getValue(); |