diff options
author | Nicholas Zolnierz <nicholas.zolnierz@mongodb.com> | 2020-01-14 17:57:01 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-14 17:57:01 +0000 |
commit | 4f329c0b056c75d67567577773039da8f3114cf1 (patch) | |
tree | 0abcebd686206873f77557e8365f74959381f88e /src | |
parent | 9d41c52dd9b2d5e49ec997bab268b1fed54b0ce4 (diff) | |
download | mongo-4f329c0b056c75d67567577773039da8f3114cf1.tar.gz |
SERVER-44477 Use correct collection count in cluster MR when determining whether to drop and reshard target
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/commands/cluster_map_reduce_cmd.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp index ef892481c02..01d34b9f318 100644 --- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp +++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp @@ -472,18 +472,16 @@ public: // We need to determine whether we need to drop and shard the output collection and // send the UUID to the shards. We will always do this if we are using replace so we // can skip this check in that case. If using merge or reduce, we only want to do this - // if the output collection does not exist or if it exists and is an empty sharded - // collection. + // if the output collection does not exist. bool shouldDropAndShard = replaceOutput; if (!replaceOutput && outputCollNss.isValid()) { - const auto primaryShard = - uassertStatusOK(shardRegistry->getShard(opCtx, outputDbInfo.primaryId())); - ScopedDbConnection conn(primaryShard->getConnString()); - if (!outputRoutingInfo.cm()) { // The output collection either exists and is unsharded, or does not exist. If // the output collection exists and is unsharded, fail because we should not go // from unsharded to sharded. + const auto primaryShard = + uassertStatusOK(shardRegistry->getShard(opCtx, outputDbInfo.primaryId())); + ScopedDbConnection conn(primaryShard->getConnString()); BSONObj listCollsCmdResponse; ok = conn->runCommand( outDB, @@ -500,14 +498,8 @@ public: // If we reach here, the collection does not exist at all. shouldDropAndShard = true; - } else { - // The output collection exists and is sharded. We need to determine whether the - // collection is empty in order to decide whether we should drop and - // re-shard it. We don't want to do this if the collection is not empty. - shouldDropAndShard = (conn->count(outputCollNss.ns()) == 0); + conn.done(); } - - conn.done(); } // If we are using replace, the output collection exists and is sharded, or the output |