diff options
author | Benety Goh <benety@mongodb.com> | 2022-12-13 09:33:35 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-12-13 15:07:59 +0000 |
commit | 87aacd32eaf12472b430223ca23a6b172b7af6f4 (patch) | |
tree | 8a0066e7830e80cd055e323bd31a9a0336dc2e59 /src/mongo/db/op_observer | |
parent | 5473d45336bfdeb7ec6c7384fd1beeaf47a4628e (diff) | |
download | mongo-87aacd32eaf12472b430223ca23a6b172b7af6f4.tar.gz |
SERVER-72006 add OpObserver::onTransactionStart()
Diffstat (limited to 'src/mongo/db/op_observer')
-rw-r--r-- | src/mongo/db/op_observer/fcv_op_observer.h | 3 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer.h | 6 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_impl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_impl.h | 1 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_noop.h | 1 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_registry.h | 7 | ||||
-rw-r--r-- | src/mongo/db/op_observer/user_write_block_mode_op_observer.h | 2 |
7 files changed, 22 insertions, 0 deletions
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 {} |