summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorSilvia Surroca <silvia.surroca@mongodb.com>2023-01-10 08:16:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-10 08:51:49 +0000
commitfb8f9ecd5e32272c8c16101640f394a7621a6a82 (patch)
tree825094f00af09c4463a9b7530f73de4d03ccbce5 /src/mongo/db
parent1d37ab71d4d1aa7baa6cea50cda7be099e53ce60 (diff)
downloadmongo-fb8f9ecd5e32272c8c16101640f394a7621a6a82.tar.gz
SERVER-71399 Jumbo chunk flag must be cleared following a chunk split
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp1
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_split_chunk_test.cpp49
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