diff options
Diffstat (limited to 'src/mongo/db/op_observer')
-rw-r--r-- | src/mongo/db/op_observer/op_observer.h | 15 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_impl.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_impl.h | 2 | ||||
-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 | 3 |
5 files changed, 19 insertions, 5 deletions
diff --git a/src/mongo/db/op_observer/op_observer.h b/src/mongo/db/op_observer/op_observer.h index 2e55e918a33..ed9a4213af6 100644 --- a/src/mongo/db/op_observer/op_observer.h +++ b/src/mongo/db/op_observer/op_observer.h @@ -521,11 +521,20 @@ public: Date_t wallClockTime) = 0; /** - * This is called when a transaction transitions into prepare while it is not primary. Example - * case can include secondary oplog application or when node was restared and tries to - * recover prepared transactions from the oplog. + * This method is called when a transaction transitions into prepare while it is not primary, + * e.g. during secondary oplog application or recoverying prepared transactions from the + * oplog after restart. The method explicitly requires a session id (i.e. does not use the + * session id attached to the opCtx) because transaction oplog application currently applies the + * oplog entries for each prepared transaction in multiple internal sessions acquired from the + * InternalSessionPool. Currently, those internal sessions are completely unrelated to the + * session for the transaction itself. For a non-retryable internal transaction, not using the + * transaction session id in the codepath here can cause the opTime for the transaction to + * show up in the chunk migration opTime buffer although the writes they correspond to are not + * retryable and therefore are discarded anyway. + * */ virtual void onTransactionPrepareNonPrimary(OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& statements, const repl::OpTime& prepareOpTime) = 0; diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp index 0b38699f6b7..8139911f37a 100644 --- a/src/mongo/db/op_observer/op_observer_impl.cpp +++ b/src/mongo/db/op_observer/op_observer_impl.cpp @@ -2143,9 +2143,10 @@ void OpObserverImpl::onTransactionPrepare( } void OpObserverImpl::onTransactionPrepareNonPrimary(OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& statements, const repl::OpTime& prepareOpTime) { - shardObserveNonPrimaryTransactionPrepare(opCtx, statements, prepareOpTime); + shardObserveNonPrimaryTransactionPrepare(opCtx, lsid, statements, prepareOpTime); } void OpObserverImpl::onTransactionAbort(OperationContext* opCtx, diff --git a/src/mongo/db/op_observer/op_observer_impl.h b/src/mongo/db/op_observer/op_observer_impl.h index c080a3d6b1e..dbebc4317e2 100644 --- a/src/mongo/db/op_observer/op_observer_impl.h +++ b/src/mongo/db/op_observer/op_observer_impl.h @@ -226,6 +226,7 @@ public: Date_t wallClockTime) final; void onTransactionPrepareNonPrimary(OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& statements, const repl::OpTime& prepareOpTime) final; @@ -266,6 +267,7 @@ private: const repl::OpTime& prepareOrCommitOptime) {} virtual void shardObserveNonPrimaryTransactionPrepare( OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& stmts, const repl::OpTime& prepareOrCommitOptime) {} diff --git a/src/mongo/db/op_observer/op_observer_noop.h b/src/mongo/db/op_observer/op_observer_noop.h index 98a4b081c34..faef9e944aa 100644 --- a/src/mongo/db/op_observer/op_observer_noop.h +++ b/src/mongo/db/op_observer/op_observer_noop.h @@ -244,6 +244,7 @@ public: Date_t wallClockTime) override {} void onTransactionPrepareNonPrimary(OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& statements, const repl::OpTime& prepareOpTime) override {} diff --git a/src/mongo/db/op_observer/op_observer_registry.h b/src/mongo/db/op_observer/op_observer_registry.h index 23eb711883e..8a2dcfb4a2f 100644 --- a/src/mongo/db/op_observer/op_observer_registry.h +++ b/src/mongo/db/op_observer/op_observer_registry.h @@ -443,11 +443,12 @@ public: } void onTransactionPrepareNonPrimary(OperationContext* opCtx, + const LogicalSessionId& lsid, const std::vector<repl::OplogEntry>& statements, const repl::OpTime& prepareOpTime) override { ReservedTimes times{opCtx}; for (auto& observer : _observers) { - observer->onTransactionPrepareNonPrimary(opCtx, statements, prepareOpTime); + observer->onTransactionPrepareNonPrimary(opCtx, lsid, statements, prepareOpTime); } } |