diff options
author | George Wangensteen <george.wangensteen@mongodb.com> | 2022-05-11 18:42:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-23 23:16:32 +0000 |
commit | c904c1853594468bbf60cc330d89a5b89b0e6365 (patch) | |
tree | e6cd5340879d1bb488cd6879d4ffa8a8ff223878 /src | |
parent | 10945bc699a008934c360b922cdd9ac5e6332af8 (diff) | |
download | mongo-c904c1853594468bbf60cc330d89a5b89b0e6365.tar.gz |
SERVER-66353 Add concurrency information to OperationContext::setAlwaysInterruptAtStepDownOrUp
Diffstat (limited to 'src')
46 files changed, 65 insertions, 59 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index a837f9aa700..77ac7c92ebc 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -268,7 +268,7 @@ public: // Ensure that this operation will be killed by the RstlKillOpThread during step-up or // stepdown. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Only allow one instance of setFeatureCompatibilityVersion to run at a time. Lock::ExclusiveLock setFCVCommandLock(opCtx->lockState(), commandMutex); diff --git a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp index 8520ae4831a..d683026b39a 100644 --- a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp @@ -185,7 +185,7 @@ public: const auto& cmd = request(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto donorService = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) ->lookupServiceByName(TenantMigrationDonorService::kServiceName); diff --git a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp index 683c4e64fe4..c4d78a2efd2 100644 --- a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp @@ -253,7 +253,7 @@ public: uassertStatusOK(tenant_migration_util::protocolTenantIdCompatibilityCheck( migrationProtocol, cmd.getTenantId().toString())); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto recipientService = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) ->lookupServiceByName(repl::TenantMigrationRecipientService:: diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index e4b522139d4..9701a28801a 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -493,8 +493,14 @@ public: /** * Sets that this operation should always get killed during stepDown and stepUp, regardless of * whether or not it's taken a write lock. + * + * Note: This function is NOT synchronized with the ReplicationStateTransitionLock! This means + * that the node's view of it's replication state can change concurrently with this function + * running - in which case your operation may _not_ be interrupted by that concurrent + * replication state change. If you need to ensure that your node does not change + * replication-state while calling this function, take the RSTL. See SERVER-66353 for more info. */ - void setAlwaysInterruptAtStepDownOrUp() { + void setAlwaysInterruptAtStepDownOrUp_UNSAFE() { _alwaysInterruptAtStepDownOrUp.store(true); } diff --git a/src/mongo/db/repl/primary_only_service.cpp b/src/mongo/db/repl/primary_only_service.cpp index 9ce8a39d504..cb79c007ced 100644 --- a/src/mongo/db/repl/primary_only_service.cpp +++ b/src/mongo/db/repl/primary_only_service.cpp @@ -104,7 +104,7 @@ public: // correctness since registering the OpCtx below will ensure that the OpCtx gets interrupted // at stepDown anyway, but setting this lets it get interrupted a little earlier in the // stepDown process. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Register the opCtx with the PrimaryOnlyService so it will get interrupted on stepDown. We // need this, and cannot simply rely on the ReplicationCoordinator to interrupt this OpCtx diff --git a/src/mongo/db/repl/primary_only_service_test.cpp b/src/mongo/db/repl/primary_only_service_test.cpp index 90e420bdafb..24da365fbe2 100644 --- a/src/mongo/db/repl/primary_only_service_test.cpp +++ b/src/mongo/db/repl/primary_only_service_test.cpp @@ -561,7 +561,7 @@ TEST_F(PrimaryOnlyServiceTest, LookupInstanceHoldingISLock) { // The RstlKillOpThread would only interrupt a read operation if the OperationContext opted // into always being interrupted. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); ASSERT_FALSE(opCtx->lockState()->wasGlobalLockTakenInModeConflictingWithWrites()); auto instance2 = diff --git a/src/mongo/db/repl/tenant_oplog_applier.cpp b/src/mongo/db/repl/tenant_oplog_applier.cpp index e32bf9371a5..e42b4e6325f 100644 --- a/src/mongo/db/repl/tenant_oplog_applier.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier.cpp @@ -428,7 +428,7 @@ TenantOplogApplier::OpTimePair TenantOplogApplier::_writeNoOpEntries( // The 'opCtx' must be interruptible on stepdown and stepup to avoid a deadlock situation with // the RSTL. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Prevent the node from being able to change state when reserving oplog slots and writing // entries. @@ -552,7 +552,7 @@ void TenantOplogApplier::_writeSessionNoOpsForRange( // forward. repl::ReplClientInfo::forClient(opCtx->getClient()).clearLastOp(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // All the ops will have the same session, so we can retain the scopedSession throughout // the loop, except when invalidated by multi-document transactions. This allows us to @@ -887,7 +887,7 @@ void TenantOplogApplier::_writeNoOpsForRange(OpObserver* opObserver, // forward. repl::ReplClientInfo::forClient(opCtx->getClient()).clearLastOp(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); AutoGetOplog oplogWrite(opCtx.get(), OplogAccessMode::kWrite); writeConflictRetry( diff --git a/src/mongo/db/s/auto_split_vector_command.cpp b/src/mongo/db/s/auto_split_vector_command.cpp index 898526db9b5..9844254520d 100644 --- a/src/mongo/db/s/auto_split_vector_command.cpp +++ b/src/mongo/db/s/auto_split_vector_command.cpp @@ -72,7 +72,7 @@ public: serverGlobalParams.clusterRole == ClusterRole::ShardServer); uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const auto& req = request(); diff --git a/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp b/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp index 5c3c95d66fb..ed857f84c08 100644 --- a/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp @@ -104,7 +104,7 @@ public: resharding::gFeatureFlagResharding.isEnabled( serverGlobalParams.featureCompatibility)); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, "_configsvrAbortReshardCollection can only be run on config servers", diff --git a/src/mongo/db/s/config/configsvr_collmod_command.cpp b/src/mongo/db/s/config/configsvr_collmod_command.cpp index c0530839b2e..e4bda1b9995 100644 --- a/src/mongo/db/s/config/configsvr_collmod_command.cpp +++ b/src/mongo/db/s/config/configsvr_collmod_command.cpp @@ -77,7 +77,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp b/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp index 617601563f0..2dacac7daea 100644 --- a/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp @@ -76,7 +76,7 @@ public: format(FMT_STRING("{} command not enabled"), definition()->getName()), resharding::gFeatureFlagResharding.isEnabled( serverGlobalParams.featureCompatibility)); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert( ErrorCodes::IllegalOperation, format(FMT_STRING("{} can only be run on config servers"), definition()->getName()), diff --git a/src/mongo/db/s/config/configsvr_configure_collection_balancing.cpp b/src/mongo/db/s/config/configsvr_configure_collection_balancing.cpp index 7c0a17d356d..136af191f6d 100644 --- a/src/mongo/db/s/config/configsvr_configure_collection_balancing.cpp +++ b/src/mongo/db/s/config/configsvr_configure_collection_balancing.cpp @@ -61,7 +61,7 @@ public: using InvocationBase::InvocationBase; void typedRun(OperationContext* opCtx) { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, str::stream() << Request::kCommandName << " can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); diff --git a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp index c5b0b0d934e..41d1679b4c9 100644 --- a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp @@ -90,7 +90,7 @@ public: "_configsvrMoveChunk can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Set the operation context read concern level to local for reads into the config database. repl::ReadConcernArgs::get(opCtx) = diff --git a/src/mongo/db/s/config/configsvr_move_range_command.cpp b/src/mongo/db/s/config/configsvr_move_range_command.cpp index 7fbb7132fcb..19db7dbe595 100644 --- a/src/mongo/db/s/config/configsvr_move_range_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_range_command.cpp @@ -69,7 +69,7 @@ public: << " can only be run on the config server", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const auto nss = ns(); const auto& req = request(); diff --git a/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp b/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp index 12f5714e11c..c6ceb8a4ca2 100644 --- a/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp @@ -59,7 +59,7 @@ public: void typedRun(OperationContext* opCtx) { const UUID& collectionUUID = request().getCollectionUUID(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, "_configsvrRemoveChunks can only be run on config servers", diff --git a/src/mongo/db/s/config/configsvr_remove_tags_command.cpp b/src/mongo/db/s/config/configsvr_remove_tags_command.cpp index 6bed282ca35..f880d9be4bf 100644 --- a/src/mongo/db/s/config/configsvr_remove_tags_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_tags_command.cpp @@ -59,7 +59,7 @@ public: void typedRun(OperationContext* opCtx) { const NamespaceString& nss = ns(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, "_configsvrRemoveTags can only be run on config servers", diff --git a/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp b/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp index 0f06bb96f1f..438a7d3227a 100644 --- a/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp +++ b/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp @@ -79,7 +79,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const auto& req = request(); diff --git a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp index 4f3e3a3a93e..23ea95511ba 100644 --- a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp +++ b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp @@ -158,7 +158,7 @@ public: // Join the existing resharding operation to prevent generating a new resharding // instance if the same command is issued consecutively due to client disconnect // etc. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); reshardCollectionJoinedExistingOperation.pauseWhileSet(opCtx); existingInstance.get()->getCoordinatorDocWrittenFuture().get(opCtx); return existingInstance; @@ -212,7 +212,7 @@ public: coordinatorDoc.setPresetReshardedChunks(request().get_presetReshardedChunks()); coordinatorDoc.setNumInitialChunks(request().getNumInitialChunks()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto registry = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()); auto service = registry->lookupServiceByName(ReshardingCoordinatorService::kServiceName); diff --git a/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp b/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp index 3f1ab04849f..628b2a837d3 100644 --- a/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp +++ b/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp @@ -51,7 +51,7 @@ public: using InvocationBase::InvocationBase; void typedRun(OperationContext* opCtx) { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const NamespaceString& nss = ns(); diff --git a/src/mongo/db/s/config/sharding_catalog_manager.cpp b/src/mongo/db/s/config/sharding_catalog_manager.cpp index 09f1ade5011..6b5c8510e9b 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager.cpp @@ -147,7 +147,7 @@ BSONObj commitOrAbortTransaction(OperationContext* opCtx, } AlternativeClientRegion acr(newClient); auto newOpCtx = cc().makeOperationContext(); - newOpCtx->setAlwaysInterruptAtStepDownOrUp(); + newOpCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); AuthorizationSession::get(newOpCtx.get()->getClient()) ->grantInternalAuthorization(newOpCtx.get()->getClient()); newOpCtx.get()->setLogicalSessionId(opCtx->getLogicalSessionId().get()); @@ -720,7 +720,7 @@ void ShardingCatalogManager::withTransaction( stdx::lock_guard<Client> lk(*client); client->setSystemOperationKillableByStepdown(lk); } - asr.opCtx()->setAlwaysInterruptAtStepDownOrUp(); + asr.opCtx()->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); AuthorizationSession::get(client)->grantInternalAuthorization(client); TxnNumber txnNumber = 0; diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index 900bddf8fd6..e8ebe638187 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -1252,7 +1252,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx, // through to all the places where they are needed would make this code more complex, and 2) // some of the operations, like creating the collection or building indexes, are not // currently supported in retryable writes. - outerOpCtx->setAlwaysInterruptAtStepDownOrUp(); + outerOpCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); { auto newClient = outerOpCtx->getServiceContext()->makeClient("MigrationCoordinator"); { @@ -1673,7 +1673,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx, // We can only ever be in this path if the recipient critical section feature is enabled. invariant(_acquireCSOnRecipient); - outerOpCtx->setAlwaysInterruptAtStepDownOrUp(); + outerOpCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto newClient = outerOpCtx->getServiceContext()->makeClient("MigrationCoordinator"); { stdx::lock_guard<Client> lk(*newClient.get()); @@ -1707,7 +1707,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx, } if (_acquireCSOnRecipient) { - outerOpCtx->setAlwaysInterruptAtStepDownOrUp(); + outerOpCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto newClient = outerOpCtx->getServiceContext()->makeClient("MigrationCoordinator"); { stdx::lock_guard<Client> lk(*newClient.get()); diff --git a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp index 97fd720e378..4b0d94e98bc 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -96,7 +96,7 @@ public: const BSONObj& cmdObj, std::string& errmsg, BSONObjBuilder& result) override { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); auto nss = NamespaceString(parseNs(dbname, cmdObj)); @@ -344,7 +344,7 @@ public: const std::string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) override { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); const auto sessionId = uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj)); diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp index 67bbaa75f2d..ee54cadb56b 100644 --- a/src/mongo/db/s/migration_util.cpp +++ b/src/mongo/db/s/migration_util.cpp @@ -372,7 +372,7 @@ ExecutorFuture<void> cleanUpRange(ServiceContext* serviceContext, } auto uniqueOpCtx = tc->makeOperationContext(); auto opCtx = uniqueOpCtx.get(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const NamespaceString& nss = deletionTask.getNss(); @@ -450,7 +450,7 @@ ExecutorFuture<void> submitRangeDeletionTask(OperationContext* opCtx, tc->setSystemOperationKillableByStepdown(lk); } auto uniqueOpCtx = tc->makeOperationContext(); - uniqueOpCtx->setAlwaysInterruptAtStepDownOrUp(); + uniqueOpCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); LOGV2(55557, "cleanUpRange failed due to keyPattern shorter than range " @@ -517,7 +517,7 @@ void resubmitRangeDeletionsOnStepUp(ServiceContext* serviceContext) { } auto opCtx = tc->makeOperationContext(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); DBDirectClient client(opCtx.get()); FindCommandRequest findCommand(NamespaceString::kRangeDeletionNamespace); @@ -540,7 +540,7 @@ void resubmitRangeDeletionsOnStepUp(ServiceContext* serviceContext) { } auto opCtx = tc->makeOperationContext(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); submitPendingDeletions(opCtx.get()); }) diff --git a/src/mongo/db/s/range_deletion_util.cpp b/src/mongo/db/s/range_deletion_util.cpp index 8bf9d4e65eb..465438c92c9 100644 --- a/src/mongo/db/s/range_deletion_util.cpp +++ b/src/mongo/db/s/range_deletion_util.cpp @@ -244,7 +244,7 @@ auto withTemporaryOperationContext(Callable&& callable, const NamespaceString& n auto opCtx = uniqueOpCtx.get(); // Ensure that this operation will be killed by the RstlKillOpThread during step-up or stepdown. - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); invariant(opCtx->shouldAlwaysInterruptAtStepDownOrUp()); { diff --git a/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp b/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp index e274c6bbf7c..9c2b78385fa 100644 --- a/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp +++ b/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp @@ -111,7 +111,7 @@ void ReshardingCleaner<Service, StateMachine, ReshardingDocument>::clean(Operati return; } - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); _waitOnMachineCompletionIfExists(opCtx); diff --git a/src/mongo/db/s/resharding/resharding_oplog_application.cpp b/src/mongo/db/s/resharding/resharding_oplog_application.cpp index 139357b11de..c2d013dfbc2 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_application.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_application.cpp @@ -72,7 +72,7 @@ void runWithTransaction(OperationContext* opCtx, stdx::lock_guard<Client> lk(*client); client->setSystemOperationKillableByStepdown(lk); } - asr.opCtx()->setAlwaysInterruptAtStepDownOrUp(); + asr.opCtx()->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); AuthorizationSession::get(client)->grantInternalAuthorization(client); TxnNumber txnNumber = 0; diff --git a/src/mongo/db/s/shardsvr_abort_reshard_collection_command.cpp b/src/mongo/db/s/shardsvr_abort_reshard_collection_command.cpp index 1208c4286d8..4e95395faaa 100644 --- a/src/mongo/db/s/shardsvr_abort_reshard_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_abort_reshard_collection_command.cpp @@ -58,7 +58,7 @@ public: using InvocationBase::InvocationBase; void typedRun(OperationContext* opCtx) { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, "_shardsvrAbortReshardCollection can only be run on shard servers", diff --git a/src/mongo/db/s/shardsvr_collmod_command.cpp b/src/mongo/db/s/shardsvr_collmod_command.cpp index fda9b426f4a..f0564913aa1 100644 --- a/src/mongo/db/s/shardsvr_collmod_command.cpp +++ b/src/mongo/db/s/shardsvr_collmod_command.cpp @@ -104,7 +104,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Since this operation is not directly writing locally we need to force its db // profile level increase in order to be logged in "<db>.system.profile" diff --git a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp index 1ffbdb06954..b321236caf1 100644 --- a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp +++ b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp @@ -79,7 +79,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // If the needsUnblock flag is set, we must have blocked the CRUD operations in the // previous phase of collMod operation for granularity updates. Unblock it now after we diff --git a/src/mongo/db/s/shardsvr_commit_reshard_collection_command.cpp b/src/mongo/db/s/shardsvr_commit_reshard_collection_command.cpp index 394bc9680bf..f4240c1eb0a 100644 --- a/src/mongo/db/s/shardsvr_commit_reshard_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_commit_reshard_collection_command.cpp @@ -58,7 +58,7 @@ public: using InvocationBase::InvocationBase; void typedRun(OperationContext* opCtx) { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::IllegalOperation, "_shardsvrCommitReshardCollection can only be run on shard servers", diff --git a/src/mongo/db/s/shardsvr_create_collection_command.cpp b/src/mongo/db/s/shardsvr_create_collection_command.cpp index 21657f758eb..bcc2e17a9fd 100644 --- a/src/mongo/db/s/shardsvr_create_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_create_collection_command.cpp @@ -74,7 +74,7 @@ public: Response typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); diff --git a/src/mongo/db/s/shardsvr_create_collection_participant_command.cpp b/src/mongo/db/s/shardsvr_create_collection_participant_command.cpp index 6f802b63811..fd7c8217403 100644 --- a/src/mongo/db/s/shardsvr_create_collection_participant_command.cpp +++ b/src/mongo/db/s/shardsvr_create_collection_participant_command.cpp @@ -76,7 +76,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); MigrationDestinationManager::cloneCollectionIndexesAndOptions( opCtx, diff --git a/src/mongo/db/s/shardsvr_drop_collection_command.cpp b/src/mongo/db/s/shardsvr_drop_collection_command.cpp index 9e7954b2d56..b7596dbca22 100644 --- a/src/mongo/db/s/shardsvr_drop_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_collection_command.cpp @@ -73,7 +73,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); try { const auto coll = Grid::get(opCtx)->catalogClient()->getCollection(opCtx, ns()); diff --git a/src/mongo/db/s/shardsvr_drop_collection_if_uuid_not_matching_command.cpp b/src/mongo/db/s/shardsvr_drop_collection_if_uuid_not_matching_command.cpp index bd0e9a9a4aa..59afb1a20df 100644 --- a/src/mongo/db/s/shardsvr_drop_collection_if_uuid_not_matching_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_collection_if_uuid_not_matching_command.cpp @@ -65,7 +65,7 @@ public: void typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassertStatusOK(dropCollectionIfUUIDNotMatching( opCtx, ns(), request().getExpectedCollectionUUID())); diff --git a/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp b/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp index d0e82460878..658c894a209 100644 --- a/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp @@ -75,7 +75,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); try { DropCollectionCoordinator::dropCollectionLocally(opCtx, ns()); diff --git a/src/mongo/db/s/shardsvr_drop_database_command.cpp b/src/mongo/db/s/shardsvr_drop_database_command.cpp index 7f1321f6718..847a25783c4 100644 --- a/src/mongo/db/s/shardsvr_drop_database_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_database_command.cpp @@ -74,7 +74,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Since this operation is not directly writing locally we need to force its db // profile level increase in order to be logged in "<db>.system.profile" diff --git a/src/mongo/db/s/shardsvr_get_stats_for_balancing_command.cpp b/src/mongo/db/s/shardsvr_get_stats_for_balancing_command.cpp index f7ac383144f..9f68063d3e5 100644 --- a/src/mongo/db/s/shardsvr_get_stats_for_balancing_command.cpp +++ b/src/mongo/db/s/shardsvr_get_stats_for_balancing_command.cpp @@ -76,7 +76,7 @@ public: Reply typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); uassert(ErrorCodes::InvalidOptions, "At least one collection must be specified", diff --git a/src/mongo/db/s/shardsvr_join_migrations_command.cpp b/src/mongo/db/s/shardsvr_join_migrations_command.cpp index 4305b860179..eeb2cdbcd3f 100644 --- a/src/mongo/db/s/shardsvr_join_migrations_command.cpp +++ b/src/mongo/db/s/shardsvr_join_migrations_command.cpp @@ -66,7 +66,7 @@ public: void typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); { Lock::GlobalLock lk(opCtx, MODE_IX); uassert(ErrorCodes::InterruptedDueToReplStateChange, diff --git a/src/mongo/db/s/shardsvr_move_range_command.cpp b/src/mongo/db/s/shardsvr_move_range_command.cpp index a5fc3db4b93..86701fd7161 100644 --- a/src/mongo/db/s/shardsvr_move_range_command.cpp +++ b/src/mongo/db/s/shardsvr_move_range_command.cpp @@ -86,7 +86,7 @@ public: void typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); // Make sure we're as up-to-date as possible with shard information. This catches the // case where we might have changed a shard's host by removing/adding a shard with the diff --git a/src/mongo/db/s/shardsvr_participant_block_command.cpp b/src/mongo/db/s/shardsvr_participant_block_command.cpp index 7735b16c46b..9ff5f58127c 100644 --- a/src/mongo/db/s/shardsvr_participant_block_command.cpp +++ b/src/mongo/db/s/shardsvr_participant_block_command.cpp @@ -71,7 +71,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto service = RecoverableCriticalSectionService::get(opCtx); const auto reason = BSON("command" diff --git a/src/mongo/db/s/shardsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/shardsvr_refine_collection_shard_key_command.cpp index 7027e3aca9d..59a674fa7ae 100644 --- a/src/mongo/db/s/shardsvr_refine_collection_shard_key_command.cpp +++ b/src/mongo/db/s/shardsvr_refine_collection_shard_key_command.cpp @@ -68,7 +68,7 @@ public: void typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const auto coordinatorCompletionFuture = [&]() -> SharedSemiFuture<void> { FixedFCVRegion fixedFcvRegion(opCtx); diff --git a/src/mongo/db/s/shardsvr_rename_collection_command.cpp b/src/mongo/db/s/shardsvr_rename_collection_command.cpp index 9373afc86b0..df68acc6801 100644 --- a/src/mongo/db/s/shardsvr_rename_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_rename_collection_command.cpp @@ -83,7 +83,7 @@ public: auto const shardingState = ShardingState::get(opCtx); uassertStatusOK(shardingState->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); diff --git a/src/mongo/db/s/shardsvr_set_allow_migrations_command.cpp b/src/mongo/db/s/shardsvr_set_allow_migrations_command.cpp index 97978dbe994..1280bf2f5e7 100644 --- a/src/mongo/db/s/shardsvr_set_allow_migrations_command.cpp +++ b/src/mongo/db/s/shardsvr_set_allow_migrations_command.cpp @@ -71,7 +71,7 @@ public: void typedRun(OperationContext* opCtx) { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); diff --git a/src/mongo/db/serverless/shard_split_commands.cpp b/src/mongo/db/serverless/shard_split_commands.cpp index caf3a44cfde..15c391a0c04 100644 --- a/src/mongo/db/serverless/shard_split_commands.cpp +++ b/src/mongo/db/serverless/shard_split_commands.cpp @@ -64,7 +64,7 @@ public: stateDoc.setRecipientTagName(cmd.getRecipientTagName()); stateDoc.setRecipientSetName(cmd.getRecipientSetName()); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto donorService = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) ->lookupServiceByName(ShardSplitDonorService::kServiceName); @@ -141,7 +141,7 @@ public: const RequestType& cmd = request(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto splitService = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) ->lookupServiceByName(ShardSplitDonorService::kServiceName); @@ -215,7 +215,7 @@ public: const RequestType& cmd = request(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); auto splitService = repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) ->lookupServiceByName(ShardSplitDonorService::kServiceName); diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 7fc21f0863e..43f15c819af 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -1467,7 +1467,7 @@ void ExecCommandDatabase::_initiateCommand() { // could conflict with transactions from a new primary. if (inMultiDocumentTransaction) { hangBeforeSettingTxnInterruptFlag.pauseWhileSet(); - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); } auto allowed = command->secondaryAllowed(opCtx->getServiceContext()); @@ -1509,7 +1509,7 @@ void ExecCommandDatabase::_initiateCommand() { // We acquire the RSTL which helps us here in two ways: // 1) It forces us to wait out any outstanding stepdown attempts. // 2) It guarantees that future RSTL holders will see the - // 'setAlwaysInterruptAtStepDownOrUp' flag we set above. + // 'setAlwaysInterruptAtStepDownOrUp_UNSAFE' flag we set above. if (inMultiDocumentTransaction) { hangAfterCheckingWritabilityForMultiDocumentTransactions.pauseWhileSet(); repl::ReplicationStateTransitionLockGuard rstl(opCtx, MODE_IX); diff --git a/src/mongo/s/commands/cluster_configure_collection_balancing.cpp b/src/mongo/s/commands/cluster_configure_collection_balancing.cpp index 2853641355f..8a287683795 100644 --- a/src/mongo/s/commands/cluster_configure_collection_balancing.cpp +++ b/src/mongo/s/commands/cluster_configure_collection_balancing.cpp @@ -61,7 +61,7 @@ public: StringData kStatusField = "status"_sd; void typedRun(OperationContext* opCtx) { - opCtx->setAlwaysInterruptAtStepDownOrUp(); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); const NamespaceString& nss = ns(); ConfigsvrConfigureCollectionBalancing configsvrRequest(nss); |