diff options
author | Allison Easton <allison.easton@mongodb.com> | 2021-09-21 13:39:28 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-21 14:39:04 +0000 |
commit | 9e1d37df7bf5bb4c8312f155bd671214f75ea296 (patch) | |
tree | c0895615554be30d482ec9923af19ea75b9745ae /src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp | |
parent | bfef41e47abf95ec8f8114552d44df6c58409c9c (diff) | |
download | mongo-9e1d37df7bf5bb4c8312f155bd671214f75ea296.tar.gz |
SERVER-52847 Make timestamp required in CollectionType and ShardCollectionType IDL
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 | 32 |
1 files changed, 10 insertions, 22 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 591917bfad4..aa25021aa4e 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 @@ -134,7 +134,6 @@ boost::optional<UUID> checkCollectionOptions(OperationContext* opCtx, } void triggerFireAndForgetShardRefreshes(OperationContext* opCtx, const CollectionType& coll) { - invariant(coll.getTimestamp()); const auto shardRegistry = Grid::get(opCtx)->shardRegistry(); const auto allShards = uassertStatusOK(Grid::get(opCtx)->catalogClient()->getAllShards( opCtx, repl::ReadConcernLevel::kLocalReadConcern)) @@ -177,7 +176,6 @@ void triggerFireAndForgetShardRefreshes(OperationContext* opCtx, const Collectio // // The chunk updates: // [{$set: { -// lastmodEpoch: <new epoch>, // min: {$arrayToObject: {$concatArrays: [ // {$objectToArray: "$min"}, // {$literal: [{k: <new_sk_suffix_1>, v: MinKey}, ...]}, @@ -225,9 +223,7 @@ void triggerFireAndForgetShardRefreshes(OperationContext* opCtx, const Collectio // }} // }}] std::pair<std::vector<BSONObj>, std::vector<BSONObj>> makeChunkAndTagUpdatesForRefine( - const BSONObj& newShardKeyFields, - OID newEpoch, - const boost::optional<Timestamp>& newTimestamp) { + const BSONObj& newShardKeyFields) { // Make the $literal objects used in the $set below to add new fields to the boundaries of the // existing chunks and tags that may include "." characters. // @@ -273,12 +269,9 @@ std::pair<std::vector<BSONObj>, std::vector<BSONObj>> makeChunkAndTagUpdatesForR << "then" << literalMaxObject << "else" << literalMinObject)))))))); - // The chunk updates change the min and max fields and unset the jumbo field. If the collection - // is in the old (pre-5.0 format, it also sets the new epoch). + // The chunk updates change the min and max fields and unset the jumbo field. std::vector<BSONObj> chunkUpdates; - chunkUpdates.emplace_back(BSON("$set" << (newTimestamp ? extendMinAndMaxModifier.getOwned() - : extendMinAndMaxModifier.addFields(BSON( - ChunkType::epoch(newEpoch)))))); + chunkUpdates.emplace_back(BSON("$set" << extendMinAndMaxModifier.getOwned())); chunkUpdates.emplace_back(BSON("$unset" << ChunkType::jumbo())); // The tag updates only change the min and max fields. @@ -319,12 +312,9 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, collType.setEpoch(newEpoch); collType.setKeyPattern(newShardKeyPattern.getKeyPattern()); - boost::optional<Timestamp> newTimestamp; - if (collType.getTimestamp()) { - auto now = VectorClock::get(opCtx)->getTime(); - newTimestamp = now.clusterTime().asTimestamp(); - collType.setTimestamp(newTimestamp); - } + auto now = VectorClock::get(opCtx)->getTime(); + Timestamp newTimestamp = now.clusterTime().asTimestamp(); + collType.setTimestamp(newTimestamp); auto updateCollectionAndChunksFn = [&](OperationContext* opCtx, TxnNumber txnNumber) { // Update the config.collections entry for the given namespace. @@ -345,13 +335,11 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, hangRefineCollectionShardKeyBeforeUpdatingChunks.pauseWhileSet(opCtx); } - auto [chunkUpdates, tagUpdates] = - makeChunkAndTagUpdatesForRefine(newFields, newEpoch, newTimestamp); + auto [chunkUpdates, tagUpdates] = makeChunkAndTagUpdatesForRefine(newFields); - // Update all config.chunks entries for the given namespace by setting (i) their epoch - // to the newly-generated objectid, (ii) their bounds for each new field in the refined - // key to MinKey (except for the global max chunk where the max bounds are set to - // MaxKey), and unsetting (iii) their jumbo field. + // Update all config.chunks entries for the given namespace by setting (i) their bounds for + // each new field in the refined key to MinKey (except for the global max chunk where the + // max bounds are set to MaxKey), and unsetting (ii) their jumbo field. const auto chunksQuery = BSON(ChunkType::collectionUUID << collType.getUuid()); writeToConfigDocumentInTxn( opCtx, |