diff options
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp index 89b59058a84..9f2c4db2f5c 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp @@ -530,6 +530,7 @@ ShardingCatalogManager::_splitChunkInTransaction(OperationContext* opCtx, newChunk.setMin(startKey); newChunk.setMax(endKey); newChunk.setEstimatedSizeBytes(boost::none); + newChunk.setJumbo(false); // build an update operation against the chunks collection of the config // database with upsert true diff --git a/src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp index eedddf232e9..930f0b06b2b 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp @@ -648,5 +648,54 @@ TEST_F(SplitChunkTest, CantCommitSplitFromChunkSplitterDuringDefragmentation) { false /* fromChunkSplitter*/)); } +TEST_F(SplitChunkTest, SplitJumboChunkShouldUnsetJumboFlag) { + const auto& nss = _nss2; + const auto collTimestamp = Timestamp(42); + const auto collEpoch = OID::gen(); + const auto collUuid = UUID::gen(); + + ChunkType chunk; + chunk.setName(OID::gen()); + chunk.setCollectionUUID(collUuid); + + auto origVersion = ChunkVersion({collEpoch, collTimestamp}, {1, 0}); + chunk.setVersion(origVersion); + chunk.setShard(ShardId(_shardName)); + chunk.setJumbo(true); + + auto chunkMin = BSON("a" << 1); + auto chunkMax = BSON("a" << 10); + chunk.setMin(chunkMin); + chunk.setMax(chunkMax); + + auto chunkSplitPoint = BSON("a" << 5); + std::vector<BSONObj> splitPoints{chunkSplitPoint}; + + setupCollection(nss, _keyPattern, {chunk}); + + ASSERT_EQ(true, chunk.getJumbo()); + + uassertStatusOK(ShardingCatalogManager::get(operationContext()) + ->commitChunkSplit(operationContext(), + nss, + collEpoch, + collTimestamp, + ChunkRange(chunkMin, chunkMax), + splitPoints, + "shard0000", + false /* fromChunkSplitter*/)); + + // Both resulting chunks must not be jumbo + auto chunkDocLeft = + getChunkDoc(operationContext(), collUuid, chunkMin, collEpoch, collTimestamp); + ASSERT_OK(chunkDocLeft.getStatus()); + + auto chunkDocRight = + getChunkDoc(operationContext(), collUuid, chunkSplitPoint, collEpoch, collTimestamp); + ASSERT_OK(chunkDocRight.getStatus()); + + ASSERT_EQ(false, chunkDocLeft.getValue().getJumbo()); + ASSERT_EQ(false, chunkDocRight.getValue().getJumbo()); +} } // namespace } // namespace mongo |