summaryrefslogtreecommitdiff
path: root/src/mongo/db/cloner.cpp
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2016-07-06 17:38:10 -0400
committerJudah Schvimer <judah@mongodb.com>2016-07-06 17:38:10 -0400
commitb3611e663fb40505340589fd75fa5d504829c609 (patch)
treeb919f526a0e36f4ee93f6e16f911bd25c7dbb6c9 /src/mongo/db/cloner.cpp
parent8833b39af63a926fe7c8538e26666f3c2f20855b (diff)
downloadmongo-b3611e663fb40505340589fd75fa5d504829c609.tar.gz
SERVER-24883 cloner should not create _id index when original collection doesn't have one
Diffstat (limited to 'src/mongo/db/cloner.cpp')
-rw-r--r--src/mongo/db/cloner.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 91fa3d94b75..9d4a5165424 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -618,7 +618,15 @@ Status Cloner::copyDb(OperationContext* txn,
uassert(18645, str::stream() << "database " << toDBName << " dropped during clone", db);
Collection* c = db->getCollection(to_name);
- if (c && !c->getIndexCatalog()->haveIdIndex(txn)) {
+ bool autoIndexId = true;
+ auto status =
+ bsonExtractBooleanFieldWithDefault(options, "autoIndexId", true, &autoIndexId);
+ if (!status.isOK()) {
+ return status;
+ }
+
+ if (c && !c->getIndexCatalog()->haveIdIndex(txn) && autoIndexId) {
+
// We need to drop objects with duplicate _ids because we didn't do a true
// snapshot and this is before applying oplog operations that occur during the
// initial sync.