diff options
author | Allison Easton <allison.easton@mongodb.com> | 2021-11-24 10:41:00 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-24 11:12:11 +0000 |
commit | e66c438f1823e75a4be3eafa1730e76c171531cc (patch) | |
tree | 68d7e3cdd6adc6464e147a454ff9115374aa3e6c /src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp | |
parent | 711f50902afffc33babc110bcaea810c9390ba1d (diff) | |
download | mongo-e66c438f1823e75a4be3eafa1730e76c171531cc.tar.gz |
SERVER-61531 Create balancer infrastructure for collection defragmentation
Diffstat (limited to 'src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp index 7933bf1b1a0..3cde42a13f7 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp @@ -53,6 +53,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/repl/repl_client_info.h" +#include "mongo/db/s/balancer/balancer.h" #include "mongo/db/s/sharding_ddl_util.h" #include "mongo/db/s/sharding_logging.h" #include "mongo/db/s/sharding_util.h" @@ -449,6 +450,7 @@ void ShardingCatalogManager::configureCollectionAutoSplit( maxChunkSizeBytes || balancerShouldMergeChunks || enableAutoSplitter); short updatedFields = 0; + bool doMerge, doSplit = false; BSONObjBuilder updateCmd; { BSONObjBuilder setBuilder(updateCmd.subobjStart("$set")); @@ -464,12 +466,12 @@ void ShardingCatalogManager::configureCollectionAutoSplit( updatedFields++; } if (balancerShouldMergeChunks) { - const bool doMerge = balancerShouldMergeChunks.get(); + doMerge = balancerShouldMergeChunks.get(); setBuilder.append(CollectionType::kBalancerShouldMergeChunksFieldName, doMerge); updatedFields++; } if (enableAutoSplitter) { - const bool doSplit = enableAutoSplitter.get(); + doSplit = enableAutoSplitter.get(); setBuilder.append(CollectionType::kNoAutoSplitFieldName, !doSplit); updatedFields++; } @@ -479,6 +481,11 @@ void ShardingCatalogManager::configureCollectionAutoSplit( unsetBuilder.append(CollectionType::kMaxChunkSizeBytesFieldName, 0); updatedFields++; } + if (balancerShouldMergeChunks && enableAutoSplitter) { + uassert(ErrorCodes::InvalidOptions, + "Autosplitter and defragmentation cannot both be enabled for a collection", + !(doMerge && doSplit)); + } if (updatedFields == 0) { return; |