diff options
19 files changed, 46 insertions, 0 deletions
diff --git a/src/mongo/db/auth/auth_op_observer.h b/src/mongo/db/auth/auth_op_observer.h index 13f08118761..f776de2b7ee 100644 --- a/src/mongo/db/auth/auth_op_observer.h +++ b/src/mongo/db/auth/auth_op_observer.h @@ -202,6 +202,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final; + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/free_mon/free_mon_op_observer.h b/src/mongo/db/free_mon/free_mon_op_observer.h index 2efc4ba4aaf..e616001f84a 100644 --- a/src/mongo/db/free_mon/free_mon_op_observer.h +++ b/src/mongo/db/free_mon/free_mon_op_observer.h @@ -202,6 +202,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/op_observer/fcv_op_observer.h b/src/mongo/db/op_observer/fcv_op_observer.h index b4fa71452d8..6cc9b7517c1 100644 --- a/src/mongo/db/op_observer/fcv_op_observer.h +++ b/src/mongo/db/op_observer/fcv_op_observer.h @@ -197,6 +197,9 @@ public: void onEmptyCapped(OperationContext* opCtx, const NamespaceString& collectionName, const UUID& uuid) final {} + + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/op_observer/op_observer.h b/src/mongo/db/op_observer/op_observer.h index 450e0ed4a70..5d9af84c73e 100644 --- a/src/mongo/db/op_observer/op_observer.h +++ b/src/mongo/db/op_observer/op_observer.h @@ -407,6 +407,12 @@ public: const UUID& uuid) = 0; /** + * The onTransaction Start method is called at the beginning of a multi-document transaction. + * It must not be called when the transaction is already in progress. + */ + virtual void onTransactionStart(OperationContext* opCtx) = 0; + + /** * The onUnpreparedTransactionCommit method is called on the commit of an unprepared * transaction, before the RecoveryUnit onCommit() is called. It must not be called when no * transaction is active. diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp index 8adac90113e..56cd6174090 100644 --- a/src/mongo/db/op_observer/op_observer_impl.cpp +++ b/src/mongo/db/op_observer/op_observer_impl.cpp @@ -1881,6 +1881,8 @@ void logCommitOrAbortForPreparedTransaction(OperationContext* opCtx, } // namespace +void OpObserverImpl::onTransactionStart(OperationContext* opCtx) {} + void OpObserverImpl::onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) { const auto& statements = transactionOperations.getOperationsForOpObserver(); diff --git a/src/mongo/db/op_observer/op_observer_impl.h b/src/mongo/db/op_observer/op_observer_impl.h index fd9bfe9bde6..1aea9c92495 100644 --- a/src/mongo/db/op_observer/op_observer_impl.h +++ b/src/mongo/db/op_observer/op_observer_impl.h @@ -212,6 +212,7 @@ public: void onEmptyCapped(OperationContext* opCtx, const NamespaceString& collectionName, const UUID& uuid) final; + void onTransactionStart(OperationContext* opCtx) final; void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final; void onBatchedWriteStart(OperationContext* opCtx) final; diff --git a/src/mongo/db/op_observer/op_observer_noop.h b/src/mongo/db/op_observer/op_observer_noop.h index c6eeca7b858..30bd69f86c5 100644 --- a/src/mongo/db/op_observer/op_observer_noop.h +++ b/src/mongo/db/op_observer/op_observer_noop.h @@ -180,6 +180,7 @@ public: void onEmptyCapped(OperationContext* opCtx, const NamespaceString& collectionName, const UUID& uuid) override {} + void onTransactionStart(OperationContext* opCtx) override {} void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override {} void onBatchedWriteStart(OperationContext* opCtx) final {} diff --git a/src/mongo/db/op_observer/op_observer_registry.h b/src/mongo/db/op_observer/op_observer_registry.h index 609d04366c1..ea3593c4c0f 100644 --- a/src/mongo/db/op_observer/op_observer_registry.h +++ b/src/mongo/db/op_observer/op_observer_registry.h @@ -410,6 +410,13 @@ public: o->onEmptyCapped(opCtx, collectionName, uuid); } + void onTransactionStart(OperationContext* opCtx) { + ReservedTimes times{opCtx}; + for (auto& o : _observers) { + o->onTransactionStart(opCtx); + } + } + void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override { ReservedTimes times{opCtx}; diff --git a/src/mongo/db/op_observer/user_write_block_mode_op_observer.h b/src/mongo/db/op_observer/user_write_block_mode_op_observer.h index 45f8289d3c3..bf07290def4 100644 --- a/src/mongo/db/op_observer/user_write_block_mode_op_observer.h +++ b/src/mongo/db/op_observer/user_write_block_mode_op_observer.h @@ -226,6 +226,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/repl/primary_only_service_op_observer.h b/src/mongo/db/repl/primary_only_service_op_observer.h index 9b06528db06..2a35458e883 100644 --- a/src/mongo/db/repl/primary_only_service_op_observer.h +++ b/src/mongo/db/repl/primary_only_service_op_observer.h @@ -204,6 +204,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/repl/tenant_migration_donor_op_observer.h b/src/mongo/db/repl/tenant_migration_donor_op_observer.h index f8efa3360db..2b7fc84b575 100644 --- a/src/mongo/db/repl/tenant_migration_donor_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_donor_op_observer.h @@ -201,6 +201,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/repl/tenant_migration_recipient_op_observer.h b/src/mongo/db/repl/tenant_migration_recipient_op_observer.h index 3ec60f50b75..7170a1e10df 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_recipient_op_observer.h @@ -203,6 +203,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/s/config_server_op_observer.h b/src/mongo/db/s/config_server_op_observer.h index d6c8e51e8d6..76685911315 100644 --- a/src/mongo/db/s/config_server_op_observer.h +++ b/src/mongo/db/s/config_server_op_observer.h @@ -204,6 +204,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) override {} + void onTransactionStart(OperationContext* opCtx) override {} + void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override {} diff --git a/src/mongo/db/s/query_analysis_op_observer.h b/src/mongo/db/s/query_analysis_op_observer.h index 5a30885556f..1ed99125cfa 100644 --- a/src/mongo/db/s/query_analysis_op_observer.h +++ b/src/mongo/db/s/query_analysis_op_observer.h @@ -203,6 +203,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/db/s/range_deleter_service_op_observer.h b/src/mongo/db/s/range_deleter_service_op_observer.h index 59afc032c71..f70ddb715d1 100644 --- a/src/mongo/db/s/range_deleter_service_op_observer.h +++ b/src/mongo/db/s/range_deleter_service_op_observer.h @@ -208,6 +208,8 @@ private: const NamespaceString& collectionName, const UUID& uuid) override {} + void onTransactionStart(OperationContext* opCtx) override {} + void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override {} diff --git a/src/mongo/db/s/resharding/resharding_op_observer.h b/src/mongo/db/s/resharding/resharding_op_observer.h index c87b5a5c0dd..1cf2b91c8bd 100644 --- a/src/mongo/db/s/resharding/resharding_op_observer.h +++ b/src/mongo/db/s/resharding/resharding_op_observer.h @@ -224,6 +224,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) override {} + void onTransactionStart(OperationContext* opCtx) override {} + void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override {} diff --git a/src/mongo/db/s/shard_server_op_observer.h b/src/mongo/db/s/shard_server_op_observer.h index c29a9b122b4..fcd7a809807 100644 --- a/src/mongo/db/s/shard_server_op_observer.h +++ b/src/mongo/db/s/shard_server_op_observer.h @@ -203,6 +203,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) override {} + void onTransactionStart(OperationContext* opCtx) override {} + void onUnpreparedTransactionCommit( OperationContext* opCtx, const TransactionOperations& transactionOperations) override {} diff --git a/src/mongo/db/serverless/shard_split_donor_op_observer.h b/src/mongo/db/serverless/shard_split_donor_op_observer.h index d3492f4cc2c..8f3fea5bda7 100644 --- a/src/mongo/db/serverless/shard_split_donor_op_observer.h +++ b/src/mongo/db/serverless/shard_split_donor_op_observer.h @@ -200,6 +200,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} diff --git a/src/mongo/idl/cluster_server_parameter_op_observer.h b/src/mongo/idl/cluster_server_parameter_op_observer.h index 4b42bff16ed..260195fe0f9 100644 --- a/src/mongo/idl/cluster_server_parameter_op_observer.h +++ b/src/mongo/idl/cluster_server_parameter_op_observer.h @@ -200,6 +200,8 @@ public: const NamespaceString& collectionName, const UUID& uuid) final {} + void onTransactionStart(OperationContext* opCtx) final {} + void onUnpreparedTransactionCommit(OperationContext* opCtx, const TransactionOperations& transactionOperations) final {} |