summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2023-03-29 13:05:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-29 14:50:21 +0000
commitdcc570ec63e5cefd18811e6d98b9518907e86d50 (patch)
treecafaa85f80f2f9cf219289dd645e72ddaba4b48a /src/mongo/s
parent58a69ba924e2ca557bf1c208fed59fc948107bd0 (diff)
downloadmongo-dcc570ec63e5cefd18811e6d98b9518907e86d50.tar.gz
SERVER-75302 Remove unused `allowAutoSplit` and `maxChunkSizeBytes` from chunk manager and shard collection type
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/catalog/type_collection.h7
-rw-r--r--src/mongo/s/catalog_cache.cpp19
-rw-r--r--src/mongo/s/catalog_cache_loader.cpp4
-rw-r--r--src/mongo/s/catalog_cache_loader.h6
-rw-r--r--src/mongo/s/catalog_cache_loader_mock.cpp2
-rw-r--r--src/mongo/s/chunk_manager.cpp20
-rw-r--r--src/mongo/s/chunk_manager.h14
-rw-r--r--src/mongo/s/chunk_manager_query_test.cpp18
-rw-r--r--src/mongo/s/collection_routing_info_targeter_test.cpp1
-rw-r--r--src/mongo/s/config_server_catalog_cache_loader.cpp2
-rw-r--r--src/mongo/s/routing_table_history_test.cpp62
11 files changed, 44 insertions, 111 deletions
diff --git a/src/mongo/s/catalog/type_collection.h b/src/mongo/s/catalog/type_collection.h
index 0f5644316d6..26d093d3896 100644
--- a/src/mongo/s/catalog/type_collection.h
+++ b/src/mongo/s/catalog/type_collection.h
@@ -147,18 +147,15 @@ public:
BSONObj getDefaultCollation() const {
return CollectionTypeBase::getDefaultCollation().get_value_or(BSONObj());
}
- void setDefaultCollation(const BSONObj& defaultCollation);
void setMaxChunkSizeBytes(int64_t value);
+ void setDefaultCollation(const BSONObj& defaultCollation);
+
bool getDefragmentCollection() const {
return CollectionTypeBase::getDefragmentCollection().get_value_or(false);
}
- bool getAllowAutoSplit() const {
- return !getNoAutoSplit().get_value_or(false);
- }
-
bool getAllowBalance() const {
return !getNoBalance() && !getDefragmentCollection();
}
diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp
index 997f5164311..a8778d9e6d9 100644
--- a/src/mongo/s/catalog_cache.cpp
+++ b/src/mongo/s/catalog_cache.cpp
@@ -110,23 +110,6 @@ std::shared_ptr<RoutingTableHistory> createUpdatedRoutingTableHistory(
return existingHistory->optRt;
}
- const auto maxChunkSize = [&]() -> boost::optional<uint64_t> {
- if (!collectionAndChunks.allowAutoSplit) {
- // maxChunkSize = 0 is an invalid chunkSize so we use it to detect noAutoSplit
- // on the steady-state path in incrementChunkOnInsertOrUpdate(...)
- return 0;
- }
- if (collectionAndChunks.maxChunkSizeBytes) {
- tassert(7032312,
- fmt::format("Invalid maxChunkSizeBytes value {} for collection '{}'",
- nss.toString(),
- collectionAndChunks.maxChunkSizeBytes.value()),
- collectionAndChunks.maxChunkSizeBytes.value() > 0);
- return uint64_t(*collectionAndChunks.maxChunkSizeBytes);
- }
- return boost::none;
- }();
-
auto newRoutingHistory = [&] {
// If we have routing info already and it's for the same collection, we're updating.
// Otherwise, we are making a whole new routing table.
@@ -135,7 +118,6 @@ std::shared_ptr<RoutingTableHistory> createUpdatedRoutingTableHistory(
{collectionAndChunks.epoch, collectionAndChunks.timestamp})) {
return existingHistory->optRt->makeUpdated(collectionAndChunks.timeseriesFields,
collectionAndChunks.reshardingFields,
- maxChunkSize,
collectionAndChunks.allowMigrations,
collectionAndChunks.changedChunks);
}
@@ -158,7 +140,6 @@ std::shared_ptr<RoutingTableHistory> createUpdatedRoutingTableHistory(
collectionAndChunks.timestamp,
collectionAndChunks.timeseriesFields,
std::move(collectionAndChunks.reshardingFields),
- maxChunkSize,
collectionAndChunks.allowMigrations,
collectionAndChunks.changedChunks);
}();
diff --git a/src/mongo/s/catalog_cache_loader.cpp b/src/mongo/s/catalog_cache_loader.cpp
index fde061a7a3b..876845b8743 100644
--- a/src/mongo/s/catalog_cache_loader.cpp
+++ b/src/mongo/s/catalog_cache_loader.cpp
@@ -50,8 +50,6 @@ CatalogCacheLoader::CollectionAndChangedChunks::CollectionAndChangedChunks(
bool collShardKeyIsUnique,
boost::optional<TypeCollectionTimeseriesFields> collTimeseriesFields,
boost::optional<TypeCollectionReshardingFields> collReshardingFields,
- boost::optional<int64_t> maxChunkSizeBytes,
- bool allowAutoSplit,
bool allowMigrations,
std::vector<ChunkType> chunks)
: epoch(std::move(epoch)),
@@ -62,8 +60,6 @@ CatalogCacheLoader::CollectionAndChangedChunks::CollectionAndChangedChunks(
shardKeyIsUnique(collShardKeyIsUnique),
timeseriesFields(std::move(collTimeseriesFields)),
reshardingFields(std::move(collReshardingFields)),
- maxChunkSizeBytes(std::move(maxChunkSizeBytes)),
- allowAutoSplit(allowAutoSplit),
allowMigrations(allowMigrations),
changedChunks(std::move(chunks)) {}
diff --git a/src/mongo/s/catalog_cache_loader.h b/src/mongo/s/catalog_cache_loader.h
index d71c658eca0..053e72b4175 100644
--- a/src/mongo/s/catalog_cache_loader.h
+++ b/src/mongo/s/catalog_cache_loader.h
@@ -75,8 +75,6 @@ public:
bool collShardKeyIsUnique,
boost::optional<TypeCollectionTimeseriesFields> collTimeseriesFields,
boost::optional<TypeCollectionReshardingFields> collReshardingFields,
- boost::optional<int64_t> maxChunkSizeBytes,
- bool allowAutoSplit,
bool allowMigrations,
std::vector<ChunkType> chunks);
@@ -96,10 +94,6 @@ public:
// populated.
boost::optional<TypeCollectionReshardingFields> reshardingFields;
- boost::optional<int64_t> maxChunkSizeBytes;
-
- bool allowAutoSplit;
-
bool allowMigrations;
// The chunks which have changed sorted by their chunkVersion. This list might potentially
diff --git a/src/mongo/s/catalog_cache_loader_mock.cpp b/src/mongo/s/catalog_cache_loader_mock.cpp
index f4c88b509b5..2c190ce6530 100644
--- a/src/mongo/s/catalog_cache_loader_mock.cpp
+++ b/src/mongo/s/catalog_cache_loader_mock.cpp
@@ -97,8 +97,6 @@ CollectionAndChangedChunks getCollectionRefresh(
swCollectionReturnValue.getValue().getUnique(),
swCollectionReturnValue.getValue().getTimeseriesFields(),
reshardingFields,
- swCollectionReturnValue.getValue().getMaxChunkSizeBytes(),
- swCollectionReturnValue.getValue().getAllowAutoSplit(),
swCollectionReturnValue.getValue().getAllowMigrations(),
std::move(chunks)};
}
diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp
index be53098d78b..181fdd63b89 100644
--- a/src/mongo/s/chunk_manager.cpp
+++ b/src/mongo/s/chunk_manager.cpp
@@ -317,7 +317,6 @@ RoutingTableHistory::RoutingTableHistory(
bool unique,
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
ChunkMap chunkMap)
: _nss(std::move(nss)),
@@ -327,7 +326,6 @@ RoutingTableHistory::RoutingTableHistory(
_unique(unique),
_timeseriesFields(std::move(timeseriesFields)),
_reshardingFields(std::move(reshardingFields)),
- _maxChunkSizeBytes(maxChunkSizeBytes),
_allowMigrations(allowMigrations),
_chunkMap(std::move(chunkMap)),
_placementVersions(_chunkMap.constructShardPlacementVersionMap()) {}
@@ -497,20 +495,6 @@ bool ChunkManager::allowMigrations() const {
return _rt->optRt->allowMigrations();
}
-bool ChunkManager::allowAutoSplit() const {
- const auto maxChunkSize = maxChunkSizeBytes();
- if (!maxChunkSize)
- return true;
-
- return *maxChunkSize != 0;
-}
-
-boost::optional<uint64_t> ChunkManager::maxChunkSizeBytes() const {
- if (!_rt->optRt)
- return boost::none;
- return _rt->optRt->maxChunkSizeBytes();
-}
-
std::string ChunkManager::toString() const {
return _rt->optRt ? _rt->optRt->toString() : "UNSHARDED";
}
@@ -578,7 +562,6 @@ RoutingTableHistory RoutingTableHistory::makeNew(
const Timestamp& timestamp,
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
const std::vector<ChunkType>& chunks) {
@@ -590,7 +573,6 @@ RoutingTableHistory RoutingTableHistory::makeNew(
std::move(unique),
std::move(timeseriesFields),
std::move(reshardingFields),
- maxChunkSizeBytes,
allowMigrations,
ChunkMap{epoch, timestamp}.createMerged(changedChunkInfos));
}
@@ -601,7 +583,6 @@ RoutingTableHistory RoutingTableHistory::makeNew(
RoutingTableHistory RoutingTableHistory::makeUpdated(
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
const std::vector<ChunkType>& changedChunks) const {
@@ -618,7 +599,6 @@ RoutingTableHistory RoutingTableHistory::makeUpdated(
isUnique(),
std::move(timeseriesFields),
std::move(reshardingFields),
- maxChunkSizeBytes,
allowMigrations,
std::move(chunkMap));
}
diff --git a/src/mongo/s/chunk_manager.h b/src/mongo/s/chunk_manager.h
index 42c14ff4d2a..2f5ca4c4aed 100644
--- a/src/mongo/s/chunk_manager.h
+++ b/src/mongo/s/chunk_manager.h
@@ -165,7 +165,6 @@ public:
const Timestamp& timestamp,
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
const std::vector<ChunkType>& chunks);
@@ -185,7 +184,6 @@ public:
RoutingTableHistory makeUpdated(
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
const std::vector<ChunkType>& changedChunks) const;
@@ -300,11 +298,6 @@ public:
return _allowMigrations;
}
- // collection default chunk size or +inf, iff no splits should happen
- boost::optional<uint64_t> maxChunkSizeBytes() const {
- return _maxChunkSizeBytes;
- }
-
private:
friend class ChunkManager;
@@ -315,7 +308,6 @@ private:
bool unique,
boost::optional<TypeCollectionTimeseriesFields> timeseriesFields,
boost::optional<TypeCollectionReshardingFields> reshardingFields,
- boost::optional<uint64_t> maxChunkSizeBytes,
bool allowMigrations,
ChunkMap chunkMap);
@@ -345,8 +337,6 @@ private:
// for this collection.
boost::optional<TypeCollectionReshardingFields> _reshardingFields;
- boost::optional<uint64_t> _maxChunkSizeBytes;
-
bool _allowMigrations;
// Map from the max for each chunk to an entry describing the chunk. The union of all chunks'
@@ -523,10 +513,6 @@ public:
*/
bool allowMigrations() const;
- bool allowAutoSplit() const;
-
- boost::optional<uint64_t> maxChunkSizeBytes() const;
-
const ShardId& dbPrimary() const {
return _dbPrimary;
}
diff --git a/src/mongo/s/chunk_manager_query_test.cpp b/src/mongo/s/chunk_manager_query_test.cpp
index 9b47635c0b6..76e9e8b5a69 100644
--- a/src/mongo/s/chunk_manager_query_test.cpp
+++ b/src/mongo/s/chunk_manager_query_test.cpp
@@ -560,8 +560,8 @@ TEST_F(ChunkManagerQueryTest, SnapshotQueryWithMoreShardsThanLatestMetadata) {
epoch,
Timestamp(1, 1),
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
+
true,
{chunk0, chunk1});
@@ -573,12 +573,14 @@ TEST_F(ChunkManagerQueryTest, SnapshotQueryWithMoreShardsThanLatestMetadata) {
chunk1.setHistory({ChunkHistory(*chunk1.getOnCurrentShardSince(), ShardId("0")),
ChunkHistory(Timestamp(1, 0), ShardId("1"))});
- ChunkManager chunkManager(
- ShardId("0"),
- DatabaseVersion(UUID::gen(), Timestamp(1, 1)),
- makeStandaloneRoutingTableHistory(oldRoutingTable.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, {chunk1})),
- Timestamp(5, 0));
+ ChunkManager chunkManager(ShardId("0"),
+ DatabaseVersion(UUID::gen(), Timestamp(1, 1)),
+ makeStandaloneRoutingTableHistory(
+ oldRoutingTable.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ {chunk1})),
+ Timestamp(5, 0));
std::set<ShardId> shardIds;
chunkManager.getShardIdsForRange(BSON("x" << MINKEY), BSON("x" << MAXKEY), &shardIds);
diff --git a/src/mongo/s/collection_routing_info_targeter_test.cpp b/src/mongo/s/collection_routing_info_targeter_test.cpp
index 4e394920de4..1404a5a795d 100644
--- a/src/mongo/s/collection_routing_info_targeter_test.cpp
+++ b/src/mongo/s/collection_routing_info_targeter_test.cpp
@@ -261,7 +261,6 @@ ChunkManager makeCustomChunkManager(const ShardKeyPattern& shardKeyPattern,
timestamp,
boost::none, // time series fields
boost::none, // resharding fields
- boost::none, // chunk size bytes
true, // allowMigration
chunks);
diff --git a/src/mongo/s/config_server_catalog_cache_loader.cpp b/src/mongo/s/config_server_catalog_cache_loader.cpp
index 2ab15aa35d6..2c11b6b2c95 100644
--- a/src/mongo/s/config_server_catalog_cache_loader.cpp
+++ b/src/mongo/s/config_server_catalog_cache_loader.cpp
@@ -74,8 +74,6 @@ CollectionAndChangedChunks getChangedChunks(OperationContext* opCtx,
coll.getUnique(),
coll.getTimeseriesFields(),
coll.getReshardingFields(),
- coll.getMaxChunkSizeBytes(),
- coll.getAllowAutoSplit(),
coll.getAllowMigrations(),
std::move(collAndChunks.second)};
}
diff --git a/src/mongo/s/routing_table_history_test.cpp b/src/mongo/s/routing_table_history_test.cpp
index ee51cfc8a63..a067f030c82 100644
--- a/src/mongo/s/routing_table_history_test.cpp
+++ b/src/mongo/s/routing_table_history_test.cpp
@@ -71,7 +71,7 @@ RoutingTableHistory splitChunk(const RoutingTableHistory& rt,
}
return rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, newChunks);
+ boost::none /* timeseriesFields */, boost::none /* reshardingFields */, true, newChunks);
}
/**
@@ -132,8 +132,7 @@ public:
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
{initChunk}));
ASSERT_EQ(_rt->numChunks(), 1ull);
@@ -204,8 +203,7 @@ TEST_F(RoutingTableHistoryTest, TestSplits) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
{chunkAll});
@@ -219,8 +217,8 @@ TEST_F(RoutingTableHistoryTest, TestSplits) {
ChunkVersion({epoch, timestamp}, {2, 2}),
kThisShard}};
- auto rt1 =
- rt.makeUpdated(boost::none /* timeseriesFields */, boost::none, boost::none, true, chunks1);
+ auto rt1 = rt.makeUpdated(
+ boost::none /* timeseriesFields */, boost::none /* reshardingFields */, true, chunks1);
auto v1 = ChunkVersion({epoch, timestamp}, {2, 2});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
@@ -239,7 +237,7 @@ TEST_F(RoutingTableHistoryTest, TestSplits) {
kThisShard}};
auto rt2 = rt1.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, chunks2);
+ boost::none /* timeseriesFields */, boost::none /* reshardingFields */, true, chunks2);
auto v2 = ChunkVersion({epoch, timestamp}, {3, 2});
ASSERT_EQ(v2, rt2.getVersion(kThisShard));
}
@@ -263,8 +261,7 @@ TEST_F(RoutingTableHistoryTest, TestReplaceEmptyChunk) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 1);
@@ -279,8 +276,10 @@ TEST_F(RoutingTableHistoryTest, TestReplaceEmptyChunk) {
ChunkVersion({epoch, timestamp}, {2, 2}),
kThisShard}};
- auto rt1 = rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, changedChunks);
+ auto rt1 = rt.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ changedChunks);
auto v1 = ChunkVersion({epoch, timestamp}, {2, 2});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
ASSERT_EQ(rt1.numChunks(), 2);
@@ -318,8 +317,7 @@ TEST_F(RoutingTableHistoryTest, TestUseLatestVersions) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 1);
@@ -338,8 +336,10 @@ TEST_F(RoutingTableHistoryTest, TestUseLatestVersions) {
ChunkVersion({epoch, timestamp}, {2, 2}),
kThisShard}};
- auto rt1 = rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, changedChunks);
+ auto rt1 = rt.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ changedChunks);
auto v1 = ChunkVersion({epoch, timestamp}, {2, 2});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
ASSERT_EQ(rt1.numChunks(), 2);
@@ -368,8 +368,7 @@ TEST_F(RoutingTableHistoryTest, TestOutOfOrderVersion) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 2);
@@ -384,8 +383,10 @@ TEST_F(RoutingTableHistoryTest, TestOutOfOrderVersion) {
ChunkVersion({epoch, timestamp}, {3, 1}),
kThisShard}};
- auto rt1 = rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, changedChunks);
+ auto rt1 = rt.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ changedChunks);
auto v1 = ChunkVersion({epoch, timestamp}, {3, 1});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
ASSERT_EQ(rt1.numChunks(), 2);
@@ -422,9 +423,8 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunks) {
false,
epoch,
timestamp,
- boost::none,
boost::none /* timeseriesFields */,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 3);
@@ -440,8 +440,10 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunks) {
ChunkVersion({epoch, timestamp}, {3, 1}),
kThisShard}};
- auto rt1 = rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, changedChunks);
+ auto rt1 = rt.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ changedChunks);
auto v1 = ChunkVersion({epoch, timestamp}, {3, 1});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
ASSERT_EQ(rt1.numChunks(), 2);
@@ -474,8 +476,7 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunksOrdering) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 3);
@@ -491,8 +492,10 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunksOrdering) {
ChunkVersion({epoch, timestamp}, {3, 1}),
kThisShard}};
- auto rt1 = rt.makeUpdated(
- boost::none /* timeseriesFields */, boost::none, boost::none, true, changedChunks);
+ auto rt1 = rt.makeUpdated(boost::none /* timeseriesFields */,
+ boost::none /* reshardingFields */,
+ true,
+ changedChunks);
auto v1 = ChunkVersion({epoch, timestamp}, {3, 1});
ASSERT_EQ(v1, rt1.getVersion(kThisShard));
ASSERT_EQ(rt1.numChunks(), 2);
@@ -543,8 +546,7 @@ TEST_F(RoutingTableHistoryTest, TestFlatten) {
epoch,
timestamp,
boost::none /* timeseriesFields */,
- boost::none,
- boost::none /* chunkSizeBytes */,
+ boost::none /* reshardingFields */,
true,
initialChunks);
ASSERT_EQ(rt.numChunks(), 2);