diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2019-04-03 17:35:29 -0400 |
---|---|---|
committer | Samy Lanka <samy.lanka@mongodb.com> | 2019-04-03 17:36:14 -0400 |
commit | 4459b439700f096a7b6287fdddde592db8934fe2 (patch) | |
tree | 9913de37d8eb6d7f9798da1dba7c3dcffb5dbb94 /src/mongo | |
parent | c7476a53ab4e33914217b61c8e81f29b8df09322 (diff) | |
download | mongo-4459b439700f096a7b6287fdddde592db8934fe2.tar.gz |
SERVER-40018 Remove ServerTransactionMetrics::getOldestActiveOpTime and supporting datastructures
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/rollback_impl.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_impl_test.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/server_transactions_metrics.cpp | 40 | ||||
-rw-r--r-- | src/mongo/db/server_transactions_metrics.h | 42 | ||||
-rw-r--r-- | src/mongo/db/transaction_metrics_observer.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/transaction_participant_test.cpp | 169 |
6 files changed, 3 insertions, 298 deletions
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp index ddbdff73e39..9edfd3d5c13 100644 --- a/src/mongo/db/repl/rollback_impl.cpp +++ b/src/mongo/db/repl/rollback_impl.cpp @@ -56,7 +56,6 @@ #include "mongo/db/s/shard_identity_rollback_notifier.h" #include "mongo/db/s/type_shard_identity.h" #include "mongo/db/server_recovery.h" -#include "mongo/db/server_transactions_metrics.h" #include "mongo/db/session_catalog_mongod.h" #include "mongo/db/storage/remove_saver.h" #include "mongo/s/catalog/type_config_version.h" @@ -251,9 +250,6 @@ Status RollbackImpl::runRollback(OperationContext* opCtx) { // abortPreparedTransactionForRollback() on any txnParticipant with a prepared transaction. killSessionsAbortAllPreparedTransactions(opCtx); - // Clear the in memory state of prepared transactions in ServerTransactionsMetrics. - ServerTransactionsMetrics::get(getGlobalServiceContext())->clearOpTimes(); - // If there were rolled back operations on any session, invalidate all sessions. // We invalidate sessions before we recover so that we avoid invalidating sessions that had // just recovered prepared transactions. diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp index 1fcc2bea878..2d11eabf1ac 100644 --- a/src/mongo/db/repl/rollback_impl_test.cpp +++ b/src/mongo/db/repl/rollback_impl_test.cpp @@ -44,7 +44,6 @@ #include "mongo/db/repl/rollback_test_fixture.h" #include "mongo/db/s/shard_identity_rollback_notifier.h" #include "mongo/db/s/type_shard_identity.h" -#include "mongo/db/server_transactions_metrics.h" #include "mongo/db/service_context.h" #include "mongo/s/catalog/type_config_version.h" #include "mongo/unittest/death_test.h" @@ -1369,32 +1368,6 @@ TEST_F(RollbackImplTest, ResetToZeroIfCountGoesNegative) { ASSERT_EQ(_storageInterface->getFinalCollectionCount(kGenericUUID), 0); } -TEST_F(RollbackImplTest, RollbackCallsClearOpTimes) { - auto op = makeOpAndRecordId(1); - _remoteOplog->setOperations({op}); - ASSERT_OK(_insertOplogEntry(op.first)); - ASSERT_OK(_insertOplogEntry(makeOp(2))); - _storageInterface->setStableTimestamp(nullptr, Timestamp(1, 1)); - - auto txnMetrics = ServerTransactionsMetrics::get(getGlobalServiceContext()); - - // Insert arbitrary values for _oldestActiveOplogEntryOpTime, _oldestActiveOplogEntryOpTimes, - // and _oldestNonMajorityCommittedOpTimes. This simulates two active prepared transactions. - txnMetrics->addActiveOpTime(repl::OpTime(Timestamp(1, 2), 0)); - txnMetrics->addActiveOpTime(repl::OpTime(Timestamp(1, 3), 0)); - - // All three variables should be populated at this time. - ASSERT(txnMetrics->getOldestActiveOpTime()); - ASSERT_EQ(*txnMetrics->getOldestActiveOpTime(), repl::OpTime(Timestamp(1, 2), 0)); - ASSERT_EQ(txnMetrics->getTotalActiveOpTimes(), 2U); - - // Call runRollback to make sure these variables get cleared. - ASSERT_OK(_rollback->runRollback(_opCtx.get())); - - ASSERT_FALSE(txnMetrics->getOldestActiveOpTime()); - ASSERT_EQ(txnMetrics->getTotalActiveOpTimes(), 0U); -} - /** * Fixture to help test that rollback records the correct information in its RollbackObserverInfo * struct. diff --git a/src/mongo/db/server_transactions_metrics.cpp b/src/mongo/db/server_transactions_metrics.cpp index 3b714fb913f..54300a1ca26 100644 --- a/src/mongo/db/server_transactions_metrics.cpp +++ b/src/mongo/db/server_transactions_metrics.cpp @@ -149,41 +149,6 @@ void ServerTransactionsMetrics::decrementCurrentPrepared() { _currentPrepared.fetchAndSubtract(1); } - -boost::optional<repl::OpTime> ServerTransactionsMetrics::getOldestActiveOpTime() const { - stdx::lock_guard<stdx::mutex> lm(_mutex); - if (_oldestActiveOplogEntryOpTimes.empty()) { - return boost::none; - } - return *(_oldestActiveOplogEntryOpTimes.begin()); -} - -void ServerTransactionsMetrics::addActiveOpTime(repl::OpTime oldestOplogEntryOpTime) { - stdx::lock_guard<stdx::mutex> lm(_mutex); - auto ret = _oldestActiveOplogEntryOpTimes.insert(oldestOplogEntryOpTime); - // If ret.second is false, the OpTime we tried to insert already existed. - invariant(ret.second, - str::stream() << "This oplog entry OpTime already exists." - << "oldestOplogEntryOpTime: " - << oldestOplogEntryOpTime.toString()); -} - -void ServerTransactionsMetrics::removeActiveOpTime(repl::OpTime oldestOplogEntryOpTime) { - stdx::lock_guard<stdx::mutex> lm(_mutex); - auto it = _oldestActiveOplogEntryOpTimes.find(oldestOplogEntryOpTime); - invariant(it != _oldestActiveOplogEntryOpTimes.end(), - str::stream() << "This oplog entry OpTime does not exist " - << "or has already been removed." - << "oldestOplogEntryOpTime: " - << oldestOplogEntryOpTime.toString()); - _oldestActiveOplogEntryOpTimes.erase(it); -} - -unsigned int ServerTransactionsMetrics::getTotalActiveOpTimes() const { - stdx::lock_guard<stdx::mutex> lm(_mutex); - return _oldestActiveOplogEntryOpTimes.size(); -} - Timestamp ServerTransactionsMetrics::_getOldestOpenUnpreparedReadTimestamp( OperationContext* opCtx) { // The history is not pinned in memory once a transaction has been prepared since reads @@ -207,11 +172,6 @@ void ServerTransactionsMetrics::updateStats(TransactionsStats* stats, OperationC ServerTransactionsMetrics::_getOldestOpenUnpreparedReadTimestamp(opCtx)); } -void ServerTransactionsMetrics::clearOpTimes() { - stdx::lock_guard<stdx::mutex> lm(_mutex); - _oldestActiveOplogEntryOpTimes.clear(); -} - namespace { class TransactionsSSS : public ServerStatusSection { public: diff --git a/src/mongo/db/server_transactions_metrics.h b/src/mongo/db/server_transactions_metrics.h index 706200409da..d5b829f6845 100644 --- a/src/mongo/db/server_transactions_metrics.h +++ b/src/mongo/db/server_transactions_metrics.h @@ -88,39 +88,10 @@ public: void decrementCurrentPrepared(); /** - * Returns the OpTime of the oldest oplog entry written across all open transactions. - * Returns boost::none if there are no transaction oplog entry OpTimes stored. - */ - boost::optional<repl::OpTime> getOldestActiveOpTime() const; - - /** - * Add the transaction's oplog entry OpTime to a set of OpTimes. - */ - void addActiveOpTime(repl::OpTime oldestOplogEntryOpTime); - - /** - * Remove the corresponding transaction oplog entry OpTime if the transaction commits or - * aborts. - */ - void removeActiveOpTime(repl::OpTime oldestOplogEntryOpTime); - - /** - * Returns the number of transaction oplog entry OpTimes currently stored. - */ - unsigned int getTotalActiveOpTimes() const; - - /** * Appends the accumulated stats to a transactions stats object. */ void updateStats(TransactionsStats* stats, OperationContext* opCtx); - /** - * Invalidates the in-memory state of prepared transactions during replication rollback by - * clearing _oldestActiveOplogEntryOpTimes. This data structure should be properly reconstructed - * during replication recovery. - */ - void clearOpTimes(); - private: /** * Returns the oldest read timestamp in use by any open unprepared transaction. This will @@ -129,14 +100,6 @@ private: */ static Timestamp _getOldestOpenUnpreparedReadTimestamp(OperationContext* opCtx); - // - // Member variables, excluding atomic variables, are labeled with the following code to - // indicate the synchronization rules for accessing them. - // - // (M) Reads and writes guarded by _mutex - // - mutable stdx::mutex _mutex; - // The number of multi-document transactions currently active. AtomicWord<unsigned long long> _currentActive{0}; @@ -166,11 +129,6 @@ private: // The current number of transactions in the prepared state. AtomicWord<unsigned long long> _currentPrepared{0}; - - // Maintain the oldest oplog entry OpTime across all active transactions. Currently, we only - // write an oplog entry for an ongoing transaction if it is in the `prepare` state. By - // maintaining an ordered set of OpTimes, the OpTime at the beginning will be the oldest. - std::set<repl::OpTime> _oldestActiveOplogEntryOpTimes; // (M) }; } // namespace mongo diff --git a/src/mongo/db/transaction_metrics_observer.cpp b/src/mongo/db/transaction_metrics_observer.cpp index 195a4d49088..365eba2d689 100644 --- a/src/mongo/db/transaction_metrics_observer.cpp +++ b/src/mongo/db/transaction_metrics_observer.cpp @@ -122,11 +122,6 @@ void TransactionMetricsObserver::onCommit(ServerTransactionsMetrics* serverTrans auto duration = durationCount<Microseconds>(_singleTransactionStats.getDuration(tickSource, curTick)); top->incrementGlobalTransactionLatencyStats(static_cast<uint64_t>(duration)); - - // Remove this transaction's oldest oplog entry OpTime if one was written. - if (oldestOplogEntryOpTime) { - serverTransactionsMetrics->removeActiveOpTime(*oldestOplogEntryOpTime); - } } void TransactionMetricsObserver::_onAbortActive( @@ -152,11 +147,6 @@ void TransactionMetricsObserver::_onAbortActive( serverTransactionsMetrics->incrementTotalPreparedThenAborted(); serverTransactionsMetrics->decrementCurrentPrepared(); } - - // Remove this transaction's oldest oplog entry OpTime if one was written. - if (oldestOplogEntryOpTime) { - serverTransactionsMetrics->removeActiveOpTime(*oldestOplogEntryOpTime); - } } void TransactionMetricsObserver::_onAbortInactive( @@ -173,11 +163,6 @@ void TransactionMetricsObserver::_onAbortInactive( // Server wide transactions metrics. // serverTransactionsMetrics->decrementCurrentInactive(); - - // Remove this transaction's oldest oplog entry OpTime if one was written. - if (oldestOplogEntryOpTime) { - serverTransactionsMetrics->removeActiveOpTime(*oldestOplogEntryOpTime); - } } void TransactionMetricsObserver::onAbort(ServerTransactionsMetrics* serverTransactionsMetrics, @@ -249,10 +234,6 @@ void TransactionMetricsObserver::onPrepare(ServerTransactionsMetrics* serverTran // _singleTransactionStats.setPreparedStartTime(curTick); - // Since we currently only write an oplog entry for an in progress transaction when it is in - // the prepare state, the prepareOpTime is currently the oldest optime written to the - // oplog for this transaction. - serverTransactionsMetrics->addActiveOpTime(prepareOpTime); serverTransactionsMetrics->incrementCurrentPrepared(); serverTransactionsMetrics->incrementTotalPrepared(); } diff --git a/src/mongo/db/transaction_participant_test.cpp b/src/mongo/db/transaction_participant_test.cpp index 20ab156251e..005211f55c7 100644 --- a/src/mongo/db/transaction_participant_test.cpp +++ b/src/mongo/db/transaction_participant_test.cpp @@ -728,9 +728,7 @@ TEST_F(TxnParticipantTest, KillSessionsDuringPrepareDoesNotAbortTransaction) { // Check that prepareTimestamp gets set. auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); ASSERT_EQ(ruPrepareTimestamp, prepareTimestamp); - // Check that the oldest prepareTimestamp is the one we just set. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); + ASSERT(_opObserver->transactionPrepared); ASSERT_FALSE(txnParticipant.transactionIsAborted()); } @@ -880,9 +878,7 @@ TEST_F(TxnParticipantTest, KillSessionsDoesNotAbortPreparedTransactions) { // Check that prepareTimestamp gets set. auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); ASSERT_EQ(ruPrepareTimestamp, prepareTimestamp); - // Check that the oldest prepareTimestamp is the one we just set. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); + txnParticipant.stashTransactionResources(opCtx()); txnParticipant.abortTransactionIfNotPrepared(opCtx()); @@ -907,9 +903,7 @@ TEST_F(TxnParticipantTest, CannotAbortArbitraryPreparedTransactions) { // Check that prepareTimestamp gets set. auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); ASSERT_EQ(ruPrepareTimestamp, prepareTimestamp); - // Check that the oldest prepareTimestamp is the one we just set. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); + txnParticipant.stashTransactionResources(opCtx()); txnParticipant.abortTransactionIfNotPrepared(opCtx()); @@ -981,10 +975,6 @@ TEST_F(TxnParticipantTest, CannotStartNewTransactionWhilePreparedTransactionInPr auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); ASSERT_EQ(ruPrepareTimestamp, prepareTimestamp); - // Check that the oldest prepareTimestamp is the one we just set. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); - txnParticipant.stashTransactionResources(opCtx()); OperationContextSession::checkIn(opCtx()); { @@ -1058,10 +1048,6 @@ DEATH_TEST_F(TxnParticipantTest, txnParticipant.addTransactionOperation(opCtx(), operation); auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); - // Check that the oldest prepareTimestamp is the one we just set. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); - _opObserver->onPreparedTransactionCommitFn = [&](OplogSlot commitOplogEntryOpTime, Timestamp commitTimestamp, @@ -1072,9 +1058,6 @@ DEATH_TEST_F(TxnParticipantTest, }; txnParticipant.commitPreparedTransaction(opCtx(), prepareTimestamp, {}); - // Check that we removed the prepareTimestamp from the set. - auto oldestActiveTS = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_FALSE(oldestActiveTS); } TEST_F(TxnParticipantTest, CannotContinueNonExistentTransaction) { @@ -3382,136 +3365,6 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowStashedAbort) { ASSERT_EQUALS(1, countLogLinesContaining(expectedTransactionInfo)); } -TEST_F(TxnParticipantTest, WhenOldestTSRemovedNextOldestBecomesNewOldest) { - auto sessionCheckout = checkOutSession(); - auto txnParticipant = TransactionParticipant::get(opCtx()); - - // Check that there are no Timestamps in the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 0U); - - txnParticipant.unstashTransactionResources(opCtx(), "prepareTransaction"); - auto firstPrepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); - // Check that we added a Timestamp to the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 1U); - // Check that the oldest prepareTimestamp is equal to firstPrepareTimestamp because there is - // only one prepared transaction on this Service. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), firstPrepareTimestamp); - ASSERT_FALSE(txnParticipant.transactionIsAborted()); - - txnParticipant.stashTransactionResources(opCtx()); - auto originalClient = Client::releaseCurrent(); - - /** - * Make a new Session, Client, OperationContext and transaction. - */ - auto service = opCtx()->getServiceContext(); - auto newClientOwned = service->makeClient("newClient"); - auto newClient = newClientOwned.get(); - Client::setCurrent(std::move(newClientOwned)); - - const TxnNumber newTxnNum = 10; - const auto newSessionId = makeLogicalSessionIdForTest(); - auto secondPrepareTimestamp = Timestamp(); - - { - auto newOpCtx = newClient->makeOperationContext(); - newOpCtx.get()->setLogicalSessionId(newSessionId); - newOpCtx.get()->setTxnNumber(newTxnNum); - - MongoDOperationContextSession newOpCtxSession(newOpCtx.get()); - auto newTxnParticipant = TransactionParticipant::get(newOpCtx.get()); - newTxnParticipant.beginOrContinue(newOpCtx.get(), newTxnNum, false, true); - newTxnParticipant.unstashTransactionResources(newOpCtx.get(), "prepareTransaction"); - - // secondPrepareTimestamp should be greater than firstPreparedTimestamp because this - // transaction was prepared after. - secondPrepareTimestamp = newTxnParticipant.prepareTransaction(newOpCtx.get(), {}); - ASSERT_GT(secondPrepareTimestamp, firstPrepareTimestamp); - // Check that we added a Timestamp to the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 2U); - // The oldest prepareTimestamp should still be firstPrepareTimestamp. - prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), firstPrepareTimestamp); - ASSERT_FALSE(txnParticipant.transactionIsAborted()); - } - - Client::releaseCurrent(); - Client::setCurrent(std::move(originalClient)); - - // Switch clients and abort the first transaction. This should cause the oldestActiveTS to be - // equal to the secondPrepareTimestamp. - txnParticipant.unstashTransactionResources(opCtx(), "prepareTransaction"); - txnParticipant.abortActiveTransaction(opCtx()); - ASSERT(txnParticipant.transactionIsAborted()); - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 1U); - prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), secondPrepareTimestamp); -} - -TEST_F(TxnParticipantTest, ReturnNullTimestampIfNoOldestActiveTimestamp) { - auto sessionCheckout = checkOutSession(); - auto txnParticipant = TransactionParticipant::get(opCtx()); - - // Check that there are no Timestamps in the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 0U); - - txnParticipant.unstashTransactionResources(opCtx(), "prepareTransaction"); - txnParticipant.prepareTransaction(opCtx(), {}); - // Check that we added a Timestamp to the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 1U); - ASSERT_FALSE(txnParticipant.transactionIsAborted()); - - txnParticipant.stashTransactionResources(opCtx()); - auto originalClient = Client::releaseCurrent(); - - /** - * Make a new Session, Client, OperationContext and transaction. - */ - auto service = opCtx()->getServiceContext(); - auto newClientOwned = service->makeClient("newClient"); - auto newClient = newClientOwned.get(); - Client::setCurrent(std::move(newClientOwned)); - - const TxnNumber newTxnNum = 10; - const auto newSessionId = makeLogicalSessionIdForTest(); - - { - auto newOpCtx = newClient->makeOperationContext(); - newOpCtx.get()->setLogicalSessionId(newSessionId); - newOpCtx.get()->setTxnNumber(newTxnNum); - - MongoDOperationContextSession newOpCtxSession(newOpCtx.get()); - auto newTxnParticipant = TransactionParticipant::get(newOpCtx.get()); - newTxnParticipant.beginOrContinue(newOpCtx.get(), newTxnNum, false, true); - newTxnParticipant.unstashTransactionResources(newOpCtx.get(), "prepareTransaction"); - - // secondPrepareTimestamp should be greater than firstPreparedTimestamp because this - // transaction was prepared after. - newTxnParticipant.prepareTransaction(newOpCtx.get(), {}); - // Check that we added a Timestamp to the set. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 2U); - // The oldest prepareTimestamp should still be firstPrepareTimestamp. - ASSERT_FALSE(txnParticipant.transactionIsAborted()); - - // Abort this transaction and check that we have decremented the total active timestamps - // count. - newTxnParticipant.abortActiveTransaction(newOpCtx.get()); - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 1U); - } - - Client::releaseCurrent(); - Client::setCurrent(std::move(originalClient)); - - // Switch clients and abort the first transaction. This means we no longer have an oldest active - // timestamp. - txnParticipant.unstashTransactionResources(opCtx(), "prepareTransaction"); - txnParticipant.abortActiveTransaction(opCtx()); - ASSERT(txnParticipant.transactionIsAborted()); - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 0U); - ASSERT_FALSE(ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime()); -} - TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { auto sessionCheckout = checkOutSession(); @@ -3525,10 +3378,6 @@ TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { auto txnParticipant = TransactionParticipant::get(opCtx()); - // Check that our metrics are initialized to their default values. - ASSERT_FALSE(ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime()); - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 0U); - // Perform an insert as a part of a transaction so that we have a transaction operation. txnParticipant.unstashTransactionResources(opCtx(), "insert"); auto operation = repl::OplogEntry::makeInsertOperation(kNss, _uuid, BSON("TestValue" << 0)); @@ -3538,13 +3387,6 @@ TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { auto prepareTimestamp = txnParticipant.prepareTransaction(opCtx(), {}); - // Check that we added a Timestamp to oldestActiveOplogEntryOpTimes. - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 1U); - - // Check that the oldest active timestamp is equal to the prepareTimestamp because there is - // only one prepared transaction. - auto prepareOpTime = ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime(); - ASSERT_EQ(prepareOpTime->getTimestamp(), prepareTimestamp); ASSERT_FALSE(txnParticipant.transactionIsAborted()); // Make sure the state of txnParticipant is populated correctly after a prepared transaction. @@ -3554,7 +3396,6 @@ TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { ASSERT_NE(txnParticipant.getActiveTxnNumber(), kUninitializedTxnNumber); txnParticipant.abortPreparedTransactionForRollback(opCtx()); - ServerTransactionsMetrics::get(opCtx())->clearOpTimes(); // After calling abortPreparedTransactionForRollback, the state of txnParticipant should be // invalidated. @@ -3562,10 +3403,6 @@ TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { ASSERT_EQ(txnParticipant.getTransactionOperationsForTest().size(), 0U); ASSERT_EQ(txnParticipant.getPrepareOpTime().getTimestamp(), Timestamp()); ASSERT_EQ(txnParticipant.getActiveTxnNumber(), kUninitializedTxnNumber); - - // After calling clearOpTimes, we should no longer have an oldestActiveOpTime. - ASSERT_FALSE(ServerTransactionsMetrics::get(opCtx())->getOldestActiveOpTime()); - ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getTotalActiveOpTimes(), 0U); } TEST_F(TxnParticipantTest, PrepareTransactionAsSecondarySetsThePrepareOpTime) { |