diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp index e44b8d4b85..b7e7e1b1e0 100644 --- a/src/mongo/db/commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands.cpp @@ -1246,6 +1246,9 @@ public: UpdateMetrics CmdUpdate::updateMetrics{"update"}; +MONGO_FAIL_POINT_DEFINE(failDeleteCommands); +static bool shouldFail = true; + class CmdDelete final : public write_ops::DeleteCmdVersion1Gen { public: AllowedOnSecondary secondaryAllowed(ServiceContext*) const final { @@ -1290,6 +1293,11 @@ public: } write_ops::DeleteCommandReply typedRun(OperationContext* opCtx) final try { + if (shouldFail && failDeleteCommands.shouldFail()) { + shouldFail = false; + uasserted(ErrorCodes::PrimarySteppedDown, "Primary stepping down"); + } + transactionChecks(opCtx, ns()); write_ops::DeleteCommandReply deleteReply; diff --git a/src/mongo/db/s/shard_collection_legacy.cpp b/src/mongo/db/s/shard_collection_legacy.cpp index 2730d7c3ee..5a315b5b21 100644 --- a/src/mongo/db/s/shard_collection_legacy.cpp +++ b/src/mongo/db/s/shard_collection_legacy.cpp @@ -84,6 +84,7 @@ MONGO_FAIL_POINT_DEFINE(pauseShardCollectionBeforeCriticalSection); MONGO_FAIL_POINT_DEFINE(pauseShardCollectionReadOnlyCriticalSection); MONGO_FAIL_POINT_DEFINE(pauseShardCollectionCommitPhase); MONGO_FAIL_POINT_DEFINE(pauseShardCollectionAfterCriticalSection); +MONGO_FAIL_POINT_DEFINE(hangAfterWritingChunks); struct ShardCollectionTargetState { UUID uuid; @@ -457,6 +458,9 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx, const InitialSplitPolicy::ShardCollectionConfig& initialChunks) { // Insert chunk documents to config.chunks on the config server. writeFirstChunksToConfig(opCtx, initialChunks); + if (hangAfterWritingChunks.shouldFail()) { + hangAfterWritingChunks.pauseWhileSet(); + } // If an error happens when contacting the config server, we don't know if the update // succeded or not, which might cause the local shard version to differ from the config // server, so we clear the metadata to allow another operation to refresh it.