summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2018-06-15 11:09:29 -0400
committerjannaerin <golden.janna@gmail.com>2018-06-20 13:16:01 -0400
commite13f3e2a932bc39017066bbd6efef602e1f952f7 (patch)
tree72049f328105c75244d26477119d3e1fb177ec25 /src/mongo/s
parentba96083d4298be9d19611fbd3d43c74bcf85bcd9 (diff)
downloadmongo-e13f3e2a932bc39017066bbd6efef602e1f952f7.tar.gz
SERVER-35609 Create initial chunk on primaryShard
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/catalog/sharding_catalog_manager_collection_operations.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_manager_collection_operations.cpp b/src/mongo/s/catalog/sharding_catalog_manager_collection_operations.cpp
index 0ce93bfd345..ebe76a0434f 100644
--- a/src/mongo/s/catalog/sharding_catalog_manager_collection_operations.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_manager_collection_operations.cpp
@@ -171,9 +171,13 @@ ChunkVersion createFirstChunks(OperationContext* opCtx,
chunk.setNS(nss.ns());
chunk.setMin(min);
chunk.setMax(max);
- chunk.setShard(shardIds[i % shardIds.size()]);
chunk.setVersion(version);
+ // It's possible there are no split points or fewer split points than total number of
+ // shards, and we need to be sure that at least one chunk is placed on the primary shard.
+ auto shardId = (i == 0) ? primaryShardId : shardIds[i % shardIds.size()];
+ chunk.setShard(shardId);
+
uassertStatusOK(Grid::get(opCtx)->catalogClient()->insertConfigDocument(
opCtx,
ChunkType::ConfigNS,