diff options
Diffstat (limited to 'src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp')
-rw-r--r-- | src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
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 658c894a209..31c19139c38 100644 --- a/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_collection_participant_command.cpp @@ -64,6 +64,10 @@ public: "directly. Participates in droping a collection."; } + bool supportsRetryableWrite() const final { + return true; + } + using Request = ShardsvrDropCollectionParticipant; class Invocation final : public InvocationBase { @@ -75,6 +79,11 @@ public: CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, opCtx->getWriteConcern()); + const auto txnParticipant = TransactionParticipant::get(opCtx); + uassert(6077301, + str::stream() << Request::kCommandName << " must be run as a retryable write", + txnParticipant); + opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); try { @@ -86,23 +95,16 @@ public: "namespace"_attr = ns()); } - // The txnParticipant will only be missing when the command was sent from a coordinator - // running an old 5.0.0 binary that didn't attach a sessionId & txnNumber. - // TODO SERVER-60773: Once 6.0 has branched out, txnParticipant must always exist. Add a - // uassert for that. - auto txnParticipant = TransactionParticipant::get(opCtx); - if (txnParticipant) { - // Since no write that generated a retryable write oplog entry with this sessionId - // and txnNumber happened, we need to make a dummy write so that the session gets - // durably persisted on the oplog. This must be the last operation done on this - // command. - DBDirectClient client(opCtx); - client.update(NamespaceString::kServerConfigurationNamespace.ns(), - BSON("_id" << Request::kCommandName), - BSON("$inc" << BSON("count" << 1)), - true /* upsert */, - false /* multi */); - } + + // Since no write that generated a retryable write oplog entry with this sessionId and + // txnNumber happened, we need to make a dummy write so that the session gets durably + // persisted on the oplog. This must be the last operation done on this command. + DBDirectClient client(opCtx); + client.update(NamespaceString::kServerConfigurationNamespace.ns(), + BSON("_id" << Request::kCommandName), + BSON("$inc" << BSON("count" << 1)), + true /* upsert */, + false /* multi */); } private: |