summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index bb935f1cfb7..78b15ad003e 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -778,6 +778,22 @@ repl::OpTime OpObserverImpl::onDropCollection(OperationContext* opCtx,
if (collectionName.coll() == DurableViewCatalog::viewsCollectionName()) {
DurableViewCatalog::onSystemViewsCollectionDrop(opCtx, collectionName);
} else if (collectionName == NamespaceString::kSessionTransactionsTableNamespace) {
+ // Disallow this drop if there are currently prepared transactions.
+ const auto sessionCatalog = SessionCatalog::get(opCtx);
+ SessionKiller::Matcher matcherAllSessions(
+ KillAllSessionsByPatternSet{makeKillAllSessionsByPattern(opCtx)});
+ bool noPreparedTxns = true;
+ sessionCatalog->scanSessions(matcherAllSessions, [&](const ObservableSession& session) {
+ auto txnParticipant = TransactionParticipant::get(session);
+ if (txnParticipant.transactionIsPrepared()) {
+ noPreparedTxns = false;
+ }
+ });
+ uassert(4852500,
+ "Unable to drop transactions table (config.transactions) while prepared "
+ "transactions are present.",
+ noPreparedTxns);
+
MongoDSessionCatalog::invalidateAllSessions(opCtx);
} else if (collectionName == NamespaceString::kConfigSettingsNamespace) {
ReadWriteConcernDefaults::get(opCtx).invalidate();