summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2012-10-01 13:29:58 -0400
committerEric Milkie <milkie@10gen.com>2012-10-02 17:46:06 -0400
commitd2d9f179a17f8b76b014b621bfc7a5bf67733633 (patch)
treec1e288bab0bf6bd76913da293ae72bd1ba39851e
parent275f68924ab8cec65fafe35193be5cbd722b3bef (diff)
downloadmongo-d2d9f179a17f8b76b014b621bfc7a5bf67733633.tar.gz
SERVER-6671 ignore dups for multikey index insertions during certain replication states
-rw-r--r--src/mongo/db/index_update.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mongo/db/index_update.cpp b/src/mongo/db/index_update.cpp
index b4471230fc1..7924dfbc7df 100644
--- a/src/mongo/db/index_update.cpp
+++ b/src/mongo/db/index_update.cpp
@@ -144,12 +144,13 @@ namespace mongo {
unsigned i = multi[j];
BSONObjSet& keys = multiKeys[j];
IndexDetails& idx = d->idx(i);
+ bool dupsAllowed = !idx.unique() || ignoreUniqueIndexes();
IndexInterface& ii = idx.idxInterface();
Ordering ordering = Ordering::make(idx.keyPattern());
d->setIndexIsMultikey(ns, i);
for( BSONObjSet::iterator k = ++keys.begin()/*skip 1*/; k != keys.end(); k++ ) {
try {
- ii.bt_insert(idx.head, loc, *k, ordering, !idx.unique(), idx);
+ ii.bt_insert(idx.head, loc, *k, ordering, dupsAllowed, idx);
} catch (AssertionException& e) {
if( e.getCode() == 10287 && (int) i == d->nIndexes ) {
DEV log() << "info: caught key already in index on bg indexing (ok)" << endl;
@@ -270,7 +271,7 @@ namespace mongo {
tlog(1) << "fastBuildIndex " << ns << " idxNo:" << idxNo << ' ' << idx.info.obj().toString() << endl;
- bool dupsAllowed = !idx.unique();
+ bool dupsAllowed = !idx.unique() || ignoreUniqueIndexes();
bool dropDups = idx.dropDups() || inDBRepair;
BSONObj order = idx.keyPattern();