diff options
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog/type_collection.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_collection.h | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_loader.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_loader.h | 18 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_loader_mock.cpp | 1 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_refresh_test.cpp | 53 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_test_fixture.cpp | 7 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_test_fixture.h | 3 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager.cpp | 21 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager.h | 29 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager_query_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager_refresh_bm.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/config_server_catalog_cache_loader.cpp | 1 | ||||
-rw-r--r-- | src/mongo/s/routing_table_history_test.cpp | 44 |
15 files changed, 147 insertions, 56 deletions
diff --git a/src/mongo/s/catalog/type_collection.cpp b/src/mongo/s/catalog/type_collection.cpp index 0141ecdc4a7..45fb266e8c1 100644 --- a/src/mongo/s/catalog/type_collection.cpp +++ b/src/mongo/s/catalog/type_collection.cpp @@ -322,8 +322,8 @@ void CollectionType::setKeyPattern(const KeyPattern& keyPattern) { _keyPattern = keyPattern; } -void CollectionType::setReshardingFields(const ReshardingFields& reshardingFields) { - _reshardingFields = reshardingFields; +void CollectionType::setReshardingFields(boost::optional<ReshardingFields> reshardingFields) { + _reshardingFields = std::move(reshardingFields); } bool CollectionType::hasSameOptions(const CollectionType& other) const { diff --git a/src/mongo/s/catalog/type_collection.h b/src/mongo/s/catalog/type_collection.h index 47190ee216a..5e94c2a1c21 100644 --- a/src/mongo/s/catalog/type_collection.h +++ b/src/mongo/s/catalog/type_collection.h @@ -194,9 +194,9 @@ public: return _distributionMode.get_value_or(DistributionMode::kSharded); } - void setReshardingFields(const ReshardingFields& reshardingFields); + void setReshardingFields(boost::optional<ReshardingFields> reshardingFields); - boost::optional<ReshardingFields> getReshardingFields() const { + const boost::optional<ReshardingFields>& getReshardingFields() const { return _reshardingFields; } diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp index c9bc5853f62..a3d87fc598c 100644 --- a/src/mongo/s/catalog_cache.cpp +++ b/src/mongo/s/catalog_cache.cpp @@ -107,7 +107,8 @@ std::shared_ptr<RoutingTableHistory> refreshCollectionRoutingInfo( if (existingRoutingInfo && existingRoutingInfo->getVersion().epoch() == collectionAndChunks.epoch) { - return existingRoutingInfo->makeUpdated(collectionAndChunks.changedChunks); + return existingRoutingInfo->makeUpdated(std::move(collectionAndChunks.reshardingFields), + collectionAndChunks.changedChunks); } auto defaultCollator = [&]() -> std::unique_ptr<CollatorInterface> { if (!collectionAndChunks.defaultCollation.isEmpty()) { @@ -123,6 +124,7 @@ std::shared_ptr<RoutingTableHistory> refreshCollectionRoutingInfo( std::move(defaultCollator), collectionAndChunks.shardKeyIsUnique, collectionAndChunks.epoch, + std::move(collectionAndChunks.reshardingFields), collectionAndChunks.changedChunks); }(); diff --git a/src/mongo/s/catalog_cache_loader.cpp b/src/mongo/s/catalog_cache_loader.cpp index f23167fa385..13792e52714 100644 --- a/src/mongo/s/catalog_cache_loader.cpp +++ b/src/mongo/s/catalog_cache_loader.cpp @@ -47,13 +47,15 @@ CatalogCacheLoader::CollectionAndChangedChunks::CollectionAndChangedChunks( const BSONObj& collShardKeyPattern, const BSONObj& collDefaultCollation, bool collShardKeyIsUnique, + boost::optional<TypeCollectionReshardingFields> collReshardingFields, std::vector<ChunkType> chunks) : uuid(collUuid), epoch(collEpoch), shardKeyPattern(collShardKeyPattern), defaultCollation(collDefaultCollation), shardKeyIsUnique(collShardKeyIsUnique), - changedChunks(chunks) {} + reshardingFields(std::move(collReshardingFields)), + changedChunks(std::move(chunks)) {} void CatalogCacheLoader::set(ServiceContext* serviceContext, std::unique_ptr<CatalogCacheLoader> loader) { diff --git a/src/mongo/s/catalog_cache_loader.h b/src/mongo/s/catalog_cache_loader.h index e451664eda1..4d8f43ba26d 100644 --- a/src/mongo/s/catalog_cache_loader.h +++ b/src/mongo/s/catalog_cache_loader.h @@ -68,12 +68,14 @@ public: */ struct CollectionAndChangedChunks { CollectionAndChangedChunks(); - CollectionAndChangedChunks(boost::optional<UUID> uuid, - const OID& collEpoch, - const BSONObj& collShardKeyPattern, - const BSONObj& collDefaultCollation, - bool collShardKeyIsUnique, - std::vector<ChunkType> chunks); + CollectionAndChangedChunks( + boost::optional<UUID> uuid, + const OID& collEpoch, + const BSONObj& collShardKeyPattern, + const BSONObj& collDefaultCollation, + bool collShardKeyIsUnique, + boost::optional<TypeCollectionReshardingFields> collReshardingFields, + std::vector<ChunkType> chunks); // Information about the entire collection boost::optional<UUID> uuid; @@ -82,6 +84,10 @@ public: BSONObj defaultCollation; bool shardKeyIsUnique{false}; + // If the collection is currently undergoing a resharding operation, the optional will be + // populated. + boost::optional<TypeCollectionReshardingFields> reshardingFields; + // The chunks which have changed sorted by their chunkVersion. This list might potentially // contain all the chunks in the collection. std::vector<ChunkType> changedChunks; diff --git a/src/mongo/s/catalog_cache_loader_mock.cpp b/src/mongo/s/catalog_cache_loader_mock.cpp index 7ed96e720a3..757b595a781 100644 --- a/src/mongo/s/catalog_cache_loader_mock.cpp +++ b/src/mongo/s/catalog_cache_loader_mock.cpp @@ -86,6 +86,7 @@ SemiFuture<CollectionAndChangedChunks> CatalogCacheLoaderMock::getChunksSince( _swCollectionReturnValue.getValue().getKeyPattern().toBSON(), _swCollectionReturnValue.getValue().getDefaultCollation(), _swCollectionReturnValue.getValue().getUnique(), + boost::none, std::move(chunks)); }) .semi(); diff --git a/src/mongo/s/catalog_cache_refresh_test.cpp b/src/mongo/s/catalog_cache_refresh_test.cpp index 27a62bd9749..70b56845eb1 100644 --- a/src/mongo/s/catalog_cache_refresh_test.cpp +++ b/src/mongo/s/catalog_cache_refresh_test.cpp @@ -66,26 +66,46 @@ protected: void expectGetCollection(OID epoch, const ShardKeyPattern& shardKeyPattern) { expectFindSendBSONObjVector(kConfigHostAndPort, [&]() { - CollectionType collType; - collType.setNs(kNss); - collType.setEpoch(epoch); - collType.setKeyPattern(shardKeyPattern.toBSON()); - collType.setUnique(false); + return std::vector<BSONObj>{getDefaultCollectionType(epoch, shardKeyPattern).toBSON()}; + }()); + } + + void expectGetCollectionWithReshardingFields(OID epoch, + const ShardKeyPattern& shardKeyPattern, + UUID reshardingUUID) { + expectFindSendBSONObjVector(kConfigHostAndPort, [&]() { + auto collType = getDefaultCollectionType(epoch, shardKeyPattern); + + TypeCollectionReshardingFields reshardingFields; + reshardingFields.setUuid(reshardingUUID); + collType.setReshardingFields(std::move(reshardingFields)); return std::vector<BSONObj>{collType.toBSON()}; }()); } + + CollectionType getDefaultCollectionType(OID epoch, const ShardKeyPattern& shardKeyPattern) { + CollectionType collType; + + collType.setNs(kNss); + collType.setEpoch(epoch); + collType.setKeyPattern(shardKeyPattern.toBSON()); + collType.setUnique(false); + + return collType; + } }; TEST_F(CatalogCacheRefreshTest, FullLoad) { const OID epoch = OID::gen(); const ShardKeyPattern shardKeyPattern(BSON("_id" << 1)); + const UUID reshardingUUID = UUID::gen(); auto future = scheduleRoutingInfoUnforcedRefresh(kNss); expectGetDatabase(); - expectGetCollection(epoch, shardKeyPattern); + expectGetCollectionWithReshardingFields(epoch, shardKeyPattern, reshardingUUID); expectFindSendBSONObjVector(kConfigHostAndPort, [&]() { ChunkVersion version(1, 0, epoch); @@ -120,6 +140,7 @@ TEST_F(CatalogCacheRefreshTest, FullLoad) { auto cm = *future.default_timed_get(); ASSERT(cm.isSharded()); ASSERT_EQ(4, cm.numChunks()); + ASSERT_EQ(reshardingUUID, cm.getReshardingFields()->getUuid()); } TEST_F(CatalogCacheRefreshTest, NoLoadIfShardNotMarkedStaleInOperationContext) { @@ -744,12 +765,14 @@ TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterSplit) { ASSERT_EQ(ChunkVersion(0, 0, version.epoch()), cm.getVersion({"1"})); } -TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMove) { +TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMoveWithReshardingFieldsAdded) { const ShardKeyPattern shardKeyPattern(BSON("_id" << 1)); + const UUID reshardingUUID = UUID::gen(); auto initialRoutingInfo( makeChunkManager(kNss, shardKeyPattern, nullptr, true, {BSON("_id" << 0)})); ASSERT_EQ(2, initialRoutingInfo.numChunks()); + ASSERT(boost::none == initialRoutingInfo.getReshardingFields()); ChunkVersion version = initialRoutingInfo.getVersion(); @@ -757,7 +780,7 @@ TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMove) { ChunkVersion expectedDestShardVersion; - expectGetCollection(version.epoch(), shardKeyPattern); + expectGetCollectionWithReshardingFields(version.epoch(), shardKeyPattern, reshardingUUID); // Return set of chunks, which represent a move expectFindSendBSONObjVector(kConfigHostAndPort, [&]() { @@ -778,16 +801,24 @@ TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMove) { auto cm = *future.default_timed_get(); ASSERT(cm.isSharded()); ASSERT_EQ(2, cm.numChunks()); + ASSERT_EQ(reshardingUUID, cm.getReshardingFields()->getUuid()); ASSERT_EQ(version, cm.getVersion()); ASSERT_EQ(version, cm.getVersion({"0"})); ASSERT_EQ(expectedDestShardVersion, cm.getVersion({"1"})); } -TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMoveLastChunk) { +TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMoveLastChunkWithReshardingFieldsRemoved) { const ShardKeyPattern shardKeyPattern(BSON("_id" << 1)); + const UUID reshardingUUID = UUID::gen(); + + TypeCollectionReshardingFields reshardingFields; + reshardingFields.setUuid(reshardingUUID); + + auto initialRoutingInfo( + makeChunkManager(kNss, shardKeyPattern, nullptr, true, {}, reshardingFields)); - auto initialRoutingInfo(makeChunkManager(kNss, shardKeyPattern, nullptr, true, {})); ASSERT_EQ(1, initialRoutingInfo.numChunks()); + ASSERT_EQ(reshardingUUID, initialRoutingInfo.getReshardingFields()->getUuid()); setupNShards(2); @@ -795,6 +826,7 @@ TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMoveLastChunk) { auto future = scheduleRoutingInfoForcedRefresh(kNss); + // The collection type won't have resharding fields this time. expectGetCollection(version.epoch(), shardKeyPattern); // Return set of chunks, which represent a move @@ -816,6 +848,7 @@ TEST_F(CatalogCacheRefreshTest, IncrementalLoadAfterMoveLastChunk) { ASSERT_EQ(version, cm.getVersion()); ASSERT_EQ(ChunkVersion(0, 0, version.epoch()), cm.getVersion({"0"})); ASSERT_EQ(version, cm.getVersion({"1"})); + ASSERT(boost::none == cm.getReshardingFields()); } } // namespace diff --git a/src/mongo/s/catalog_cache_test_fixture.cpp b/src/mongo/s/catalog_cache_test_fixture.cpp index ba9bb4a4ddb..71e02e67fac 100644 --- a/src/mongo/s/catalog_cache_test_fixture.cpp +++ b/src/mongo/s/catalog_cache_test_fixture.cpp @@ -108,7 +108,8 @@ ChunkManager CatalogCacheTestFixture::makeChunkManager( const ShardKeyPattern& shardKeyPattern, std::unique_ptr<CollatorInterface> defaultCollator, bool unique, - const std::vector<BSONObj>& splitPoints) { + const std::vector<BSONObj>& splitPoints, + boost::optional<ReshardingFields> reshardingFields) { ChunkVersion version(1, 0, OID::gen()); const BSONObj databaseBSON = [&]() { @@ -127,6 +128,10 @@ ChunkManager CatalogCacheTestFixture::makeChunkManager( coll.setDefaultCollation(defaultCollator->getSpec().toBSON()); } + if (reshardingFields) { + coll.setReshardingFields(std::move(reshardingFields)); + } + return coll.toBSON(); }(); diff --git a/src/mongo/s/catalog_cache_test_fixture.h b/src/mongo/s/catalog_cache_test_fixture.h index 412e2455911..fb5238a2ba9 100644 --- a/src/mongo/s/catalog_cache_test_fixture.h +++ b/src/mongo/s/catalog_cache_test_fixture.h @@ -52,7 +52,8 @@ protected: const ShardKeyPattern& shardKeyPattern, std::unique_ptr<CollatorInterface> defaultCollator, bool unique, - const std::vector<BSONObj>& splitPoints); + const std::vector<BSONObj>& splitPoints, + boost::optional<ReshardingFields> reshardingFields = boost::none); /** * Invalidates the catalog cache for 'kNss' and schedules a thread to invoke the blocking 'get' diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp index a159b3f0ca0..bb1dd46caec 100644 --- a/src/mongo/s/chunk_manager.cpp +++ b/src/mongo/s/chunk_manager.cpp @@ -300,17 +300,20 @@ ChunkMap::_overlappingBounds(const BSONObj& min, const BSONObj& max, bool isMaxI ShardVersionTargetingInfo::ShardVersionTargetingInfo(const OID& epoch) : shardVersion(0, 0, epoch) {} -RoutingTableHistory::RoutingTableHistory(NamespaceString nss, - boost::optional<UUID> uuid, - KeyPattern shardKeyPattern, - std::unique_ptr<CollatorInterface> defaultCollator, - bool unique, - ChunkMap chunkMap) +RoutingTableHistory::RoutingTableHistory( + NamespaceString nss, + boost::optional<UUID> uuid, + KeyPattern shardKeyPattern, + std::unique_ptr<CollatorInterface> defaultCollator, + bool unique, + boost::optional<TypeCollectionReshardingFields> reshardingFields, + ChunkMap chunkMap) : _nss(std::move(nss)), _uuid(uuid), _shardKeyPattern(shardKeyPattern), _defaultCollator(std::move(defaultCollator)), _unique(unique), + _reshardingFields(std::move(reshardingFields)), _chunkMap(std::move(chunkMap)), _shardVersions(_chunkMap.constructShardVersionMap()) {} @@ -707,17 +710,20 @@ std::shared_ptr<RoutingTableHistory> RoutingTableHistory::makeNew( std::unique_ptr<CollatorInterface> defaultCollator, bool unique, OID epoch, + boost::optional<TypeCollectionReshardingFields> reshardingFields, const std::vector<ChunkType>& chunks) { return RoutingTableHistory(std::move(nss), std::move(uuid), std::move(shardKeyPattern), std::move(defaultCollator), std::move(unique), + boost::none, ChunkMap{epoch}) - .makeUpdated(chunks); + .makeUpdated(std::move(reshardingFields), chunks); } std::shared_ptr<RoutingTableHistory> RoutingTableHistory::makeUpdated( + boost::optional<TypeCollectionReshardingFields> reshardingFields, const std::vector<ChunkType>& changedChunks) { // It's possible for there to be one chunk in changedChunks without the routing table having @@ -746,6 +752,7 @@ std::shared_ptr<RoutingTableHistory> RoutingTableHistory::makeUpdated( KeyPattern(getShardKeyPattern().getKeyPattern()), CollatorInterface::cloneCollator(getDefaultCollator()), isUnique(), + std::move(reshardingFields), std::move(chunkMap))); } diff --git a/src/mongo/s/chunk_manager.h b/src/mongo/s/chunk_manager.h index 4ac16f5fa18..0a2270c7b77 100644 --- a/src/mongo/s/chunk_manager.h +++ b/src/mongo/s/chunk_manager.h @@ -39,6 +39,7 @@ #include "mongo/s/chunk_version.h" #include "mongo/s/client/shard.h" #include "mongo/s/database_version_gen.h" +#include "mongo/s/resharding/type_collection_fields_gen.h" #include "mongo/s/shard_key_pattern.h" #include "mongo/stdx/unordered_map.h" #include "mongo/util/concurrency/ticketholder.h" @@ -150,6 +151,9 @@ public: * * The "chunks" vector must contain the chunk routing information sorted in ascending order by * chunk version, and adhere to the requirements of the routing table update algorithm. + * + * The existence of "reshardingFields" inside the optional implies that this field was present + * inside the config.collections entry when refreshing. */ static std::shared_ptr<RoutingTableHistory> makeNew( NamespaceString nss, @@ -158,6 +162,7 @@ public: std::unique_ptr<CollatorInterface> defaultCollator, bool unique, OID epoch, + boost::optional<TypeCollectionReshardingFields> reshardingFields, const std::vector<ChunkType>& chunks); /** @@ -166,8 +171,15 @@ public: * * The changes in "changedChunks" must be sorted in ascending order by chunk version, and adhere * to the requirements of the routing table update algorithm. + * + * The existence of "reshardingFields" inside the optional implies that this field was present + * inside the config.collections entry when refreshing. An uninitialized "reshardingFields" + * parameter implies that the field was not present, and will clear any currently held + * resharding fields inside the resulting RoutingTableHistory. */ - std::shared_ptr<RoutingTableHistory> makeUpdated(const std::vector<ChunkType>& changedChunks); + std::shared_ptr<RoutingTableHistory> makeUpdated( + boost::optional<TypeCollectionReshardingFields> reshardingFields, + const std::vector<ChunkType>& changedChunks); const NamespaceString& nss() const { return _nss; @@ -261,6 +273,10 @@ public: return _uuid; } + const boost::optional<TypeCollectionReshardingFields>& getReshardingFields() const { + return _reshardingFields; + } + private: friend class ChunkManager; @@ -269,6 +285,7 @@ private: KeyPattern shardKeyPattern, std::unique_ptr<CollatorInterface> defaultCollator, bool unique, + boost::optional<TypeCollectionReshardingFields> reshardingFields, ChunkMap chunkMap); ChunkVersion _getVersion(const ShardId& shardName, bool throwOnStaleShard) const; @@ -288,6 +305,12 @@ private: // Whether the sharding key is unique bool _unique; + // The set of fields related to an ongoing resharding operation involving this collection. The + // presence of the type inside the optional indicates that the collection is involved in a + // resharding operation, and that these fields were present in the config.collections entry + // for this collection. + const boost::optional<TypeCollectionReshardingFields> _reshardingFields; + // Map from the max for each chunk to an entry describing the chunk. The union of all chunks' // ranges must cover the complete space from [MinKey, MaxKey). ChunkMap _chunkMap; @@ -485,6 +508,10 @@ public: return _rt->getUUID(); } + const boost::optional<TypeCollectionReshardingFields>& getReshardingFields() const { + return _rt->getReshardingFields(); + } + private: ShardId _dbPrimary; DatabaseVersion _dbVersion; diff --git a/src/mongo/s/chunk_manager_query_test.cpp b/src/mongo/s/chunk_manager_query_test.cpp index 823166d96e9..772304ce006 100644 --- a/src/mongo/s/chunk_manager_query_test.cpp +++ b/src/mongo/s/chunk_manager_query_test.cpp @@ -513,7 +513,7 @@ TEST_F(ChunkManagerQueryTest, SnapshotQueryWithMoreShardsThanLatestMetadata) { chunk1.setName(OID::gen()); auto oldRoutingTable = RoutingTableHistory::makeNew( - kNss, boost::none, BSON("x" << 1), nullptr, false, epoch, {chunk0, chunk1}); + kNss, boost::none, BSON("x" << 1), nullptr, false, epoch, boost::none, {chunk0, chunk1}); // Simulate move chunk {x: 0} to shard 0. Effectively moving all remaining chunks to shard 0. version.incMajor(); @@ -522,7 +522,7 @@ TEST_F(ChunkManagerQueryTest, SnapshotQueryWithMoreShardsThanLatestMetadata) { chunk1.setHistory({ChunkHistory(Timestamp(20, 0), ShardId("0")), ChunkHistory(Timestamp(1, 0), ShardId("1"))}); - auto newRoutingTable = oldRoutingTable->makeUpdated({chunk1}); + auto newRoutingTable = oldRoutingTable->makeUpdated(boost::none, {chunk1}); ChunkManager chunkManager( ShardId("0"), DatabaseVersion(UUID::gen(), 1), newRoutingTable, Timestamp(5, 0)); diff --git a/src/mongo/s/chunk_manager_refresh_bm.cpp b/src/mongo/s/chunk_manager_refresh_bm.cpp index 41a33a964b6..69a71e221e2 100644 --- a/src/mongo/s/chunk_manager_refresh_bm.cpp +++ b/src/mongo/s/chunk_manager_refresh_bm.cpp @@ -73,7 +73,7 @@ CollectionMetadata makeChunkManagerWithShardSelector(int nShards, } auto routingTableHistory = RoutingTableHistory::makeNew( - kNss, UUID::gen(), shardKeyPattern, nullptr, true, collEpoch, chunks); + kNss, UUID::gen(), shardKeyPattern, nullptr, true, collEpoch, boost::none, chunks); return CollectionMetadata( ChunkManager( ShardId("Shard0"), DatabaseVersion(UUID::gen(), 1), routingTableHistory, boost::none), @@ -102,7 +102,7 @@ MONGO_COMPILER_NOINLINE auto makeChunkManagerWithOptimalBalancedDistribution(int MONGO_COMPILER_NOINLINE auto runIncrementalUpdate(const CollectionMetadata& cm, const std::vector<ChunkType>& newChunks) { - auto rt = cm.getChunkManager()->getRoutingHistory()->makeUpdated(newChunks); + auto rt = cm.getChunkManager()->getRoutingHistory()->makeUpdated(boost::none, newChunks); return std::make_unique<CollectionMetadata>( ChunkManager(ShardId("shard0"), DatabaseVersion(UUID::gen(), 1), rt, boost::none), ShardId("shard0")); @@ -169,7 +169,7 @@ auto BM_FullBuildOfChunkManager(benchmark::State& state, ShardSelectorFn selectS for (auto keepRunning : state) { auto routingTableHistory = RoutingTableHistory::makeNew( - collName, UUID::gen(), shardKeyPattern, nullptr, true, collEpoch, chunks); + collName, UUID::gen(), shardKeyPattern, nullptr, true, collEpoch, boost::none, chunks); benchmark::DoNotOptimize(CollectionMetadata(ChunkManager(ShardId("shard0"), DatabaseVersion(UUID::gen(), 1), routingTableHistory, diff --git a/src/mongo/s/config_server_catalog_cache_loader.cpp b/src/mongo/s/config_server_catalog_cache_loader.cpp index 0c0084bf2d4..35102ddf39c 100644 --- a/src/mongo/s/config_server_catalog_cache_loader.cpp +++ b/src/mongo/s/config_server_catalog_cache_loader.cpp @@ -114,6 +114,7 @@ CollectionAndChangedChunks getChangedChunks(OperationContext* opCtx, coll.getKeyPattern().toBSON(), coll.getDefaultCollation(), coll.getUnique(), + coll.getReshardingFields(), std::move(changedChunks)); } diff --git a/src/mongo/s/routing_table_history_test.cpp b/src/mongo/s/routing_table_history_test.cpp index 0d43cc9ba41..7e9b501fdce 100644 --- a/src/mongo/s/routing_table_history_test.cpp +++ b/src/mongo/s/routing_table_history_test.cpp @@ -70,7 +70,7 @@ std::shared_ptr<RoutingTableHistory> splitChunk( curVersion.incMajor(); newChunks.emplace_back(kNss, range, curVersion, kThisShard); } - return rt->makeUpdated(newChunks); + return rt->makeUpdated(boost::none, newChunks); } /** @@ -162,7 +162,7 @@ public: kThisShard}; _rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), _shardKeyPattern, nullptr, false, epoch, {initChunk}); + kNss, UUID::gen(), _shardKeyPattern, nullptr, false, epoch, boost::none, {initChunk}); ASSERT_EQ(_rt->numChunks(), 1ull); // Should only be one @@ -326,7 +326,7 @@ TEST_F(RoutingTableHistoryTest, TestSplits) { kThisShard}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, {chunkAll}); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, {chunkAll}); std::vector<ChunkType> chunks1 = { ChunkType{kNss, @@ -338,7 +338,7 @@ TEST_F(RoutingTableHistoryTest, TestSplits) { ChunkVersion{2, 2, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(chunks1); + auto rt1 = rt->makeUpdated(boost::none, chunks1); auto v1 = ChunkVersion{2, 2, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); @@ -356,7 +356,7 @@ TEST_F(RoutingTableHistoryTest, TestSplits) { ChunkVersion{3, 2, epoch}, kThisShard}}; - auto rt2 = rt1->makeUpdated(chunks2); + auto rt2 = rt1->makeUpdated(boost::none, chunks2); auto v2 = ChunkVersion{3, 2, epoch}; ASSERT_EQ(v2, rt2->getVersion(kThisShard)); } @@ -375,8 +375,14 @@ TEST_F(RoutingTableHistoryTest, TestReplaceChunk) { ChunkVersion{2, 2, epoch}, kThisShard}}; - auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, {initialChunks}); + auto rt = RoutingTableHistory::makeNew(kNss, + UUID::gen(), + getShardKeyPattern(), + nullptr, + false, + epoch, + boost::none, + {initialChunks}); std::vector<ChunkType> changedChunks = { ChunkType{kNss, @@ -384,7 +390,7 @@ TEST_F(RoutingTableHistoryTest, TestReplaceChunk) { ChunkVersion{2, 2, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{2, 2, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -414,7 +420,7 @@ TEST_F(RoutingTableHistoryTest, TestReplaceEmptyChunk) { kThisShard}}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 1); @@ -428,7 +434,7 @@ TEST_F(RoutingTableHistoryTest, TestReplaceEmptyChunk) { ChunkVersion{2, 2, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{2, 2, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -458,7 +464,7 @@ TEST_F(RoutingTableHistoryTest, TestUseLatestVersions) { kThisShard}}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 1); @@ -476,7 +482,7 @@ TEST_F(RoutingTableHistoryTest, TestUseLatestVersions) { ChunkVersion{2, 2, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{2, 2, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -497,7 +503,7 @@ TEST_F(RoutingTableHistoryTest, TestOutOfOrderVersion) { kThisShard}}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 2); @@ -511,7 +517,7 @@ TEST_F(RoutingTableHistoryTest, TestOutOfOrderVersion) { ChunkVersion{3, 1, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{3, 1, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -541,7 +547,7 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunks) { kThisShard}}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 3); ASSERT_EQ(rt->getVersion(), ChunkVersion(2, 2, epoch)); @@ -556,7 +562,7 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunks) { ChunkVersion{3, 1, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{3, 1, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -581,7 +587,7 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunksOrdering) { kThisShard}}; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 3); ASSERT_EQ(rt->getVersion(), ChunkVersion(2, 2, epoch)); @@ -596,7 +602,7 @@ TEST_F(RoutingTableHistoryTest, TestMergeChunksOrdering) { ChunkVersion{3, 1, epoch}, kThisShard}}; - auto rt1 = rt->makeUpdated(changedChunks); + auto rt1 = rt->makeUpdated(boost::none, changedChunks); auto v1 = ChunkVersion{3, 1, epoch}; ASSERT_EQ(v1, rt1->getVersion(kThisShard)); ASSERT_EQ(rt1->numChunks(), 2); @@ -639,7 +645,7 @@ TEST_F(RoutingTableHistoryTest, TestFlatten) { }; auto rt = RoutingTableHistory::makeNew( - kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, initialChunks); + kNss, UUID::gen(), getShardKeyPattern(), nullptr, false, epoch, boost::none, initialChunks); ASSERT_EQ(rt->numChunks(), 2); ASSERT_EQ(rt->getVersion(), ChunkVersion(4, 1, epoch)); |