diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2019-04-01 12:11:49 -0400 |
---|---|---|
committer | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2019-04-01 12:11:49 -0400 |
commit | 5b2225b699fd47358e37aff0eaeab1285a1bd1cb (patch) | |
tree | 95a4fd123ee97e58b3f10c0e9bab2902cc1b8578 /src/mongo/db/transaction_metrics_observer.h | |
parent | e13ea89917fde4fa2182f5db3aba289f0a4d84fd (diff) | |
download | mongo-5b2225b699fd47358e37aff0eaeab1285a1bd1cb.tar.gz |
SERVER-38257: Make transactionMetricsObserver.onAbort self-contained
- onAbort() calls _onAbortActive() if _singleTransactionStats.isActive(), otherwise it calls _onAbortInactive().
- add test case
Diffstat (limited to 'src/mongo/db/transaction_metrics_observer.h')
-rw-r--r-- | src/mongo/db/transaction_metrics_observer.h | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/src/mongo/db/transaction_metrics_observer.h b/src/mongo/db/transaction_metrics_observer.h index 71e01ce3e13..cbb00d21fd9 100644 --- a/src/mongo/db/transaction_metrics_observer.h +++ b/src/mongo/db/transaction_metrics_observer.h @@ -80,30 +80,15 @@ public: bool wasPrepared); /** - * Updates relevant metrics when an active transaction aborts. Also removes this transaction's - * oldest oplog entry OpTime from the oldestActiveOplogEntryOpTimes set if it is not - * boost::none. - * Finally, updates an entry in oldestNonMajorityCommittedOpTimes to include its abort OpTime. + * Updates relevant metrics when a transaction aborts. + * See _onAbortActive() and _onAbortInactive(). */ - void onAbortActive(ServerTransactionsMetrics* serverTransactionsMetrics, - TickSource* tickSource, - boost::optional<repl::OpTime> oldestOplogEntryOpTime, - boost::optional<repl::OpTime> abortOpTime, - Top* top, - bool wasPrepared); - - /** - * Updates relevant metrics when an inactive transaction aborts. Also removes this transaction's - * oldest oplog entry OpTime from the oldestActiveOplogEntryOpTimes set if it is not - * boost::none. - * Does not accept an optional abortOpTime parameter because we cannot abort an inactive - * prepared transaction. Instead, uses boost::none as the abortOpTime, which subsequently will - * not modify oldestNonMajorityCommittedOpTimes. - */ - void onAbortInactive(ServerTransactionsMetrics* serverTransactionsMetrics, - TickSource* tickSource, - boost::optional<repl::OpTime> oldestOplogEntryOpTime, - Top* top); + void onAbort(ServerTransactionsMetrics* serverTransactionsMetrics, + TickSource* tickSource, + boost::optional<repl::OpTime> oldestOplogEntryOpTime, + boost::optional<repl::OpTime> abortOpTime, + Top* top, + bool wasPrepared); /** * Adds the prepareOpTime, which is currently the Timestamp of the first oplog entry written by @@ -144,6 +129,32 @@ private: TickSource* tickSource, Top* top); + /** + * Updates relevant metrics when an active transaction aborts. Also removes this transaction's + * oldest oplog entry OpTime from the oldestActiveOplogEntryOpTimes set if it is not + * boost::none. + * Finally, updates an entry in oldestNonMajorityCommittedOpTimes to include its abort OpTime. + */ + void _onAbortActive(ServerTransactionsMetrics* serverTransactionsMetrics, + TickSource* tickSource, + boost::optional<repl::OpTime> oldestOplogEntryOpTime, + boost::optional<repl::OpTime> abortOpTime, + Top* top, + bool wasPrepared); + + /** + * Updates relevant metrics when an inactive transaction aborts. Also removes this transaction's + * oldest oplog entry OpTime from the oldestActiveOplogEntryOpTimes set if it is not + * boost::none. + * Does not accept an optional abortOpTime parameter because we cannot abort an inactive + * prepared transaction. Instead, uses boost::none as the abortOpTime, which subsequently will + * not modify oldestNonMajorityCommittedOpTimes. + */ + void _onAbortInactive(ServerTransactionsMetrics* serverTransactionsMetrics, + TickSource* tickSource, + boost::optional<repl::OpTime> oldestOplogEntryOpTime, + Top* top); + // Tracks metrics for a single multi-document transaction. SingleTransactionStats _singleTransactionStats; }; |