summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2018-02-09 13:24:26 -0500
committerEsha Maharishi <esha.maharishi@mongodb.com>2018-02-12 23:38:23 -0500
commit63eb274727e70752ceb76ed21fd6e4182bc4ddf4 (patch)
tree68a1769936361580f343a9b40be3a4b2952d0501
parent200871c6f995ff1e51ca6565deecb01778b15d47 (diff)
downloadmongo-63eb274727e70752ceb76ed21fd6e4182bc4ddf4.tar.gz
SERVER-33234 dropIndexes on mongos should ignore IndexNotFound from individual shards if some shard returned success
(cherry picked from commit f2e168877ab5efb45ec583ca3b4d05a423fe9d54)
-rw-r--r--src/mongo/s/commands/commands_public.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index d1613c8967c..6f2249f37c5 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -274,6 +274,13 @@ public:
const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj));
LOG(1) << "dropIndexes: " << nss << " cmd:" << redact(cmdObj);
+ // If the collection is sharded, we target all shards rather than just shards that own
+ // chunks for the collection, because some shard may have previously owned chunks but no
+ // longer does (and so, may have the index). However, we ignore NamespaceNotFound errors
+ // from individual shards, because some shards may have never owned chunks for the
+ // collection. We additionally ignore IndexNotFound errors, because the index may not have
+ // been built on a shard if the earlier createIndexes command coincided with the shard
+ // receiving its first chunk for the collection (see SERVER-31715).
auto shardResponses = uassertStatusOK(
scatterGatherOnlyVersionIfUnsharded(opCtx,
dbName,
@@ -281,8 +288,11 @@ public:
filterCommandRequestForPassthrough(cmdObj),
ReadPreferenceSetting::get(opCtx),
Shard::RetryPolicy::kNotIdempotent));
- return appendRawResponses(
- opCtx, &errmsg, &output, std::move(shardResponses), {ErrorCodes::NamespaceNotFound});
+ return appendRawResponses(opCtx,
+ &errmsg,
+ &output,
+ std::move(shardResponses),
+ {ErrorCodes::NamespaceNotFound, ErrorCodes::IndexNotFound});
}
} dropIndexesCmd;