diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2022-02-28 20:48:31 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-11 14:58:38 +0000 |
commit | 3de01a4acc71ab5241826fdbcb642d4ae000753f (patch) | |
tree | 9f994ab0a4affbd44c28fdf615edfc5ddc174ead /src | |
parent | 8ff255e3b85a0f4c74c2fa3842e292076926c6ff (diff) | |
download | mongo-3de01a4acc71ab5241826fdbcb642d4ae000753f.tar.gz |
SERVER-64057 Comment the shard/databaseVersion arguments for the shard role
Diffstat (limited to 'src')
8 files changed, 25 insertions, 11 deletions
diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp index 1e68272a9f9..2d51dc92697 100644 --- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp @@ -397,7 +397,7 @@ bool ShardServerProcessInterface::setExpectedDbVersion(OperationContext* opCtx, "Expected db version must match known db version", knownDBVersion == dbVersion); } else { - OperationShardingState::setShardRole(opCtx, nss, boost::none, dbVersion); + OperationShardingState::setShardRole(opCtx, nss, boost::none /* shardVersion */, dbVersion); } return false; @@ -411,7 +411,8 @@ void ShardServerProcessInterface::setExpectedShardVersion( if (oss.hasShardVersion(nss)) { invariant(oss.getShardVersion(nss) == chunkVersion); } else { - OperationShardingState::setShardRole(opCtx, nss, chunkVersion, boost::none); + OperationShardingState::setShardRole( + opCtx, nss, chunkVersion, boost::none /* databaseVersion */); } } diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index 45106690b43..9c5ea37cbcb 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -1353,6 +1353,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> attachCursorToPipeline( return shardVersionRetry( expCtx->opCtx, catalogCache, expCtx->ns, "targeting pipeline to attach cursors"_sd, [&]() { auto pipelineToTarget = pipeline->clone(); + if (shardTargetingPolicy == ShardTargetingPolicy::kNotAllowed || shouldAlwaysAttachLocalCursorForNamespace(expCtx->ns)) { return expCtx->mongoProcessInterface->attachCursorSourceToPipelineForLocalRead( diff --git a/src/mongo/db/s/collection_metadata_filtering_test.cpp b/src/mongo/db/s/collection_metadata_filtering_test.cpp index f7c994c706a..2cca83e70c1 100644 --- a/src/mongo/db/s/collection_metadata_filtering_test.cpp +++ b/src/mongo/db/s/collection_metadata_filtering_test.cpp @@ -125,8 +125,10 @@ protected: _manager = std::make_shared<MetadataManager>( getServiceContext(), kNss, executor(), CollectionMetadata(cm, ShardId("0"))); - OperationShardingState::setShardRole( - operationContext(), kNss, cm.getVersion(ShardId("0")), boost::none); + OperationShardingState::setShardRole(operationContext(), + kNss, + cm.getVersion(ShardId("0")) /* shardVersion */, + boost::none /* databaseVersion */); } std::shared_ptr<MetadataManager> _manager; diff --git a/src/mongo/db/s/collection_sharding_runtime_test.cpp b/src/mongo/db/s/collection_sharding_runtime_test.cpp index 540e7f5363f..c227443690d 100644 --- a/src/mongo/db/s/collection_sharding_runtime_test.cpp +++ b/src/mongo/db/s/collection_sharding_runtime_test.cpp @@ -81,8 +81,10 @@ protected: boost::none); if (!OperationShardingState::isOperationVersioned(opCtx)) { - OperationShardingState::setShardRole( - opCtx, kTestNss, cm.getVersion(ShardId("0")), boost::none); + OperationShardingState::setShardRole(opCtx, + kTestNss, + cm.getVersion(ShardId("0")) /* shardVersion */, + boost::none /* databaseVersion */); } return CollectionMetadata(std::move(cm), ShardId("0")); diff --git a/src/mongo/db/s/op_observer_sharding_test.cpp b/src/mongo/db/s/op_observer_sharding_test.cpp index 8ea4dd63904..2620a746751 100644 --- a/src/mongo/db/s/op_observer_sharding_test.cpp +++ b/src/mongo/db/s/op_observer_sharding_test.cpp @@ -44,11 +44,12 @@ const NamespaceString kTestNss("TestDB", "TestColl"); void setCollectionFilteringMetadata(OperationContext* opCtx, CollectionMetadata metadata) { AutoGetCollection autoColl(opCtx, kTestNss, MODE_X); - const auto version = metadata.getShardVersion(); + const auto shardVersion = metadata.getShardVersion(); CollectionShardingRuntime::get(opCtx, kTestNss) ->setFilteringMetadata(opCtx, std::move(metadata)); - OperationShardingState::setShardRole(opCtx, kTestNss, version, boost::none); + OperationShardingState::setShardRole( + opCtx, kTestNss, shardVersion, boost::none /* databaseVersion */); } class DocumentKeyStateTest : public ShardServerTestFixture { diff --git a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp index fadc390a510..10a777709f0 100644 --- a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp +++ b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp @@ -476,7 +476,8 @@ TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnDeletesInTran auto env = setupReshardingEnv(opCtx, true); - OperationShardingState::setShardRole(opCtx, kNss, env.version, env.dbVersion); + OperationShardingState::setShardRole( + opCtx, kNss, env.version /* shardVersion */, env.dbVersion /* databaseVersion */); runInTransaction(opCtx, [&]() { deleteDoc(opCtx, kNss, BSON("_id" << 0), env); }); // Look for destined recipient in latest oplog entry. Since this write was done in a diff --git a/src/mongo/db/s/resharding/resharding_oplog_application.cpp b/src/mongo/db/s/resharding/resharding_oplog_application.cpp index 0842f9aa88c..694e7e2e993 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_application.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_application.cpp @@ -81,7 +81,10 @@ void runWithTransaction(OperationContext* opCtx, // the temporary resharding collection. We attach shard version IGNORED to the write operations // and leave it to ReshardingOplogBatchApplier::applyBatch() to retry on a StaleConfig exception // to allow the collection metadata information to be recovered. - ScopedSetShardRole scopedSetShardRole(asr.opCtx(), nss, ChunkVersion::IGNORED(), boost::none); + ScopedSetShardRole scopedSetShardRole(asr.opCtx(), + nss, + ChunkVersion::IGNORED() /* shardVersion */, + boost::none /* databaseVersion */); MongoDOperationContextSession ocs(asr.opCtx()); auto txnParticipant = TransactionParticipant::get(asr.opCtx()); diff --git a/src/mongo/db/s/sharding_write_router_bm.cpp b/src/mongo/db/s/sharding_write_router_bm.cpp index 1118117e90d..7a47c6eed21 100644 --- a/src/mongo/db/s/sharding_write_router_bm.cpp +++ b/src/mongo/db/s/sharding_write_router_bm.cpp @@ -148,7 +148,10 @@ std::unique_ptr<CatalogCacheMock> createCatalogCacheMock(OperationContext* opCtx std::make_unique<CollectionShardingStateFactoryShard>(opCtx->getServiceContext())); OperationShardingState::setShardRole( - opCtx, kNss, chunkManager.getVersion(originatorShard), boost::none); + opCtx, + kNss, + chunkManager.getVersion(originatorShard) /* shardVersion */, + boost::none /* databaseVersion */); // Configuring the filtering metadata such that calls to getCollectionDescription return what we // want. Specifically the reshardingFields are what we use. Its specified by the chunkManager. |