diff options
author | Benety Goh <benety@mongodb.com> | 2022-10-12 12:17:43 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-12 17:24:28 +0000 |
commit | 4d9be19d1cf86049fe54e6632950c384b2b7eaa6 (patch) | |
tree | cfbdba90722e738d5efac1c8e2e9d9af26170d47 | |
parent | 77aec6e6dcd06f19a8a9ac29786a1948366659c4 (diff) | |
download | mongo-4d9be19d1cf86049fe54e6632950c384b2b7eaa6.tar.gz |
SERVER-69749 OpObserver::preTransactionPrepare() accepts TransactionOperations
22 files changed, 30 insertions, 31 deletions
diff --git a/src/mongo/db/auth/auth_op_observer.h b/src/mongo/db/auth/auth_op_observer.h index 3437f89dd99..51d0e7c5af8 100644 --- a/src/mongo/db/auth/auth_op_observer.h +++ b/src/mongo/db/auth/auth_op_observer.h @@ -217,7 +217,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } 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 b33131e4e7d..edff328eab7 100644 --- a/src/mongo/db/free_mon/free_mon_op_observer.h +++ b/src/mongo/db/free_mon/free_mon_op_observer.h @@ -217,7 +217,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } diff --git a/src/mongo/db/op_observer/fcv_op_observer.h b/src/mongo/db/op_observer/fcv_op_observer.h index f4d77200ed8..bae90557db4 100644 --- a/src/mongo/db/op_observer/fcv_op_observer.h +++ b/src/mongo/db/op_observer/fcv_op_observer.h @@ -211,7 +211,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } diff --git a/src/mongo/db/op_observer/op_observer.h b/src/mongo/db/op_observer/op_observer.h index f0371ce6e94..548670c33ea 100644 --- a/src/mongo/db/op_observer/op_observer.h +++ b/src/mongo/db/op_observer/op_observer.h @@ -487,14 +487,15 @@ public: * The 'wallClockTime' is the time to record as wall clock time on oplog entries resulting from * transaction preparation. * - * The 'statements' are the list of CRUD operations to be applied in this transaction. The - * operations may be modified by setting pre-image and post-image oplog entry timestamps. + * The 'transactionOperations' contains the list of CRUD operations to be applied in this + * transaction. The operations may be modified by setting pre-image and post-image oplog entry + * timestamps. */ virtual std::unique_ptr<ApplyOpsOplogSlotAndOperationAssignment> preTransactionPrepare( OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) = 0; + TransactionOperations* transactionOperations) = 0; /** * The onTransactionPrepare method is called when an atomic transaction is prepared. It must be diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp index d784138e4ad..391de491530 100644 --- a/src/mongo/db/op_observer/op_observer_impl.cpp +++ b/src/mongo/db/op_observer/op_observer_impl.cpp @@ -2178,7 +2178,8 @@ std::unique_ptr<OpObserver::ApplyOpsOplogSlotAndOperationAssignment> OpObserverImpl::preTransactionPrepare(OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) { + TransactionOperations* transactionOperations) { + auto* statements = transactionOperations->getMutableOperationsForOpObserver(); auto applyOpsOplogSlotAndOperationAssignment = getApplyOpsOplogSlotAndOperationAssignmentForTransaction( opCtx, reservedSlots, true /*prepare*/, *statements); diff --git a/src/mongo/db/op_observer/op_observer_impl.h b/src/mongo/db/op_observer/op_observer_impl.h index 7445ff5dc69..58ab37979f6 100644 --- a/src/mongo/db/op_observer/op_observer_impl.h +++ b/src/mongo/db/op_observer/op_observer_impl.h @@ -229,7 +229,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final; + TransactionOperations* transactionOperations) final; void onTransactionPrepare( OperationContext* opCtx, diff --git a/src/mongo/db/op_observer/op_observer_impl_test.cpp b/src/mongo/db/op_observer/op_observer_impl_test.cpp index 25dfeee2408..4c7b546f925 100644 --- a/src/mongo/db/op_observer/op_observer_impl_test.cpp +++ b/src/mongo/db/op_observer/op_observer_impl_test.cpp @@ -1147,8 +1147,8 @@ protected: size_t numberOfPrePostImagesToWrite = 0) { auto txnOps = txnParticipant().retrieveCompletedTransactionOperations(opCtx()); auto currentTime = Date_t::now(); - auto applyOpsAssignment = opObserver().preTransactionPrepare( - opCtx(), reservedSlots, currentTime, txnOps->getMutableOperationsForOpObserver()); + auto applyOpsAssignment = + opObserver().preTransactionPrepare(opCtx(), reservedSlots, currentTime, txnOps); opCtx()->recoveryUnit()->setPrepareTimestamp(prepareOpTime.getTimestamp()); opObserver().onTransactionPrepare(opCtx(), reservedSlots, diff --git a/src/mongo/db/op_observer/op_observer_noop.h b/src/mongo/db/op_observer/op_observer_noop.h index 9a91fc7601e..8263a6e6373 100644 --- a/src/mongo/db/op_observer/op_observer_noop.h +++ b/src/mongo/db/op_observer/op_observer_noop.h @@ -196,7 +196,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { return nullptr; } void onTransactionPrepare( diff --git a/src/mongo/db/op_observer/op_observer_registry.h b/src/mongo/db/op_observer/op_observer_registry.h index 93a4cda1197..8c98bfc7da0 100644 --- a/src/mongo/db/op_observer/op_observer_registry.h +++ b/src/mongo/db/op_observer/op_observer_registry.h @@ -434,12 +434,12 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { std::unique_ptr<ApplyOpsOplogSlotAndOperationAssignment> applyOpsOplogSlotAndOperationAssignment; for (auto&& observer : _observers) { - auto applyOpsAssignment = - observer->preTransactionPrepare(opCtx, reservedSlots, wallClockTime, statements); + auto applyOpsAssignment = observer->preTransactionPrepare( + opCtx, reservedSlots, wallClockTime, transactionOperations); tassert(6278501, "More than one OpObserver returned operation to \"applyOps\" assignment", !(applyOpsAssignment && applyOpsOplogSlotAndOperationAssignment)); 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 e401278faf1..540ee34d126 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 @@ -241,7 +241,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } 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 e55386403d9..9c56950c19f 100644 --- a/src/mongo/db/repl/primary_only_service_op_observer.h +++ b/src/mongo/db/repl/primary_only_service_op_observer.h @@ -219,7 +219,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } 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 0bc7e0022f5..510ec3c56a1 100644 --- a/src/mongo/db/repl/tenant_migration_donor_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_donor_op_observer.h @@ -216,7 +216,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } 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 06684b2bc87..7b1d51fe334 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_recipient_op_observer.h @@ -218,7 +218,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } diff --git a/src/mongo/db/s/config_server_op_observer.h b/src/mongo/db/s/config_server_op_observer.h index 00d6a2d7309..c93992dc155 100644 --- a/src/mongo/db/s/config_server_op_observer.h +++ b/src/mongo/db/s/config_server_op_observer.h @@ -219,7 +219,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { return nullptr; } diff --git a/src/mongo/db/s/query_analysis_op_observer.h b/src/mongo/db/s/query_analysis_op_observer.h index 1dc18c6ce42..b47d1fe5c19 100644 --- a/src/mongo/db/s/query_analysis_op_observer.h +++ b/src/mongo/db/s/query_analysis_op_observer.h @@ -218,7 +218,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } 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 1ac62baadd8..264dec90134 100644 --- a/src/mongo/db/s/range_deleter_service_op_observer.h +++ b/src/mongo/db/s/range_deleter_service_op_observer.h @@ -223,7 +223,7 @@ private: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { return nullptr; } diff --git a/src/mongo/db/s/resharding/resharding_op_observer.h b/src/mongo/db/s/resharding/resharding_op_observer.h index ae48c80fa74..3cedd23dd6d 100644 --- a/src/mongo/db/s/resharding/resharding_op_observer.h +++ b/src/mongo/db/s/resharding/resharding_op_observer.h @@ -239,7 +239,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { return nullptr; } diff --git a/src/mongo/db/s/shard_server_op_observer.h b/src/mongo/db/s/shard_server_op_observer.h index a14ddbb87fc..2d6388a5c98 100644 --- a/src/mongo/db/s/shard_server_op_observer.h +++ b/src/mongo/db/s/shard_server_op_observer.h @@ -218,7 +218,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override { + TransactionOperations* transactionOperations) override { return nullptr; } 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 797a86966a1..efe1d43fc3b 100644 --- a/src/mongo/db/serverless/shard_split_donor_op_observer.h +++ b/src/mongo/db/serverless/shard_split_donor_op_observer.h @@ -215,7 +215,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } diff --git a/src/mongo/db/transaction/transaction_participant.cpp b/src/mongo/db/transaction/transaction_participant.cpp index bbc259739f1..81d09138ba9 100644 --- a/src/mongo/db/transaction/transaction_participant.cpp +++ b/src/mongo/db/transaction/transaction_participant.cpp @@ -1672,10 +1672,7 @@ Timestamp TransactionParticipant::Participant::prepareTransaction( auto opObserver = opCtx->getServiceContext()->getOpObserver(); const auto wallClockTime = opCtx->getServiceContext()->getFastClockSource()->now(); auto applyOpsOplogSlotAndOperationAssignment = opObserver->preTransactionPrepare( - opCtx, - reservedSlots, - wallClockTime, - completedTransactionOperations->getMutableOperationsForOpObserver()); + opCtx, reservedSlots, wallClockTime, completedTransactionOperations); opCtx->recoveryUnit()->setPrepareTimestamp(prepareOplogSlot.getTimestamp()); opCtx->getWriteUnitOfWork()->prepare(); diff --git a/src/mongo/db/transaction/transaction_participant_test.cpp b/src/mongo/db/transaction/transaction_participant_test.cpp index 057c4a87a69..61adbe097b6 100644 --- a/src/mongo/db/transaction/transaction_participant_test.cpp +++ b/src/mongo/db/transaction/transaction_participant_test.cpp @@ -103,7 +103,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) override; + TransactionOperations* transactionOperations) override; void onTransactionPrepare( OperationContext* opCtx, @@ -156,7 +156,7 @@ std::unique_ptr<OpObserver::ApplyOpsOplogSlotAndOperationAssignment> OpObserverMock::preTransactionPrepare(OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) { + TransactionOperations* transactionOperations) { return std::make_unique<OpObserver::ApplyOpsOplogSlotAndOperationAssignment>( OpObserver::ApplyOpsOplogSlotAndOperationAssignment{{}, {}}); } diff --git a/src/mongo/idl/cluster_server_parameter_op_observer.h b/src/mongo/idl/cluster_server_parameter_op_observer.h index 42452afe7b8..2b378c98fe3 100644 --- a/src/mongo/idl/cluster_server_parameter_op_observer.h +++ b/src/mongo/idl/cluster_server_parameter_op_observer.h @@ -221,7 +221,7 @@ public: OperationContext* opCtx, const std::vector<OplogSlot>& reservedSlots, Date_t wallClockTime, - std::vector<repl::ReplOperation>* statements) final { + TransactionOperations* transactionOperations) final { return nullptr; } |