diff options
author | Matt Diener <matt.diener@mongodb.com> | 2022-10-12 20:19:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-12 21:06:32 +0000 |
commit | 02a79726b9109458d4eb37b010d58faf7332929b (patch) | |
tree | 03b789383d087ea67e627f8201e8f75b99a9e18e /src/mongo/s/transaction_router_test.cpp | |
parent | 112d7ad9e8eab0c0f8839a98d78b712b2eff9cbd (diff) | |
download | mongo-02a79726b9109458d4eb37b010d58faf7332929b.tar.gz |
SERVER-70264 make slowMS and sampleRate atomic
Diffstat (limited to 'src/mongo/s/transaction_router_test.cpp')
-rw-r--r-- | src/mongo/s/transaction_router_test.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp index d6e26b2d436..837099e53fd 100644 --- a/src/mongo/s/transaction_router_test.cpp +++ b/src/mongo/s/transaction_router_test.cpp @@ -3221,7 +3221,7 @@ protected: txnRouter().beginOrContinueTxn( operationContext(), kTxnNumber, TransactionRouter::TransactionActions::kStart); txnRouter().setDefaultAtClusterTime(operationContext()); - tickSource()->advance(Milliseconds(serverGlobalParams.slowMS + 1)); + tickSource()->advance(Milliseconds(serverGlobalParams.slowMS.load() + 1)); } void beginRecoverCommitWithDefaultTxnNumber() { @@ -3234,7 +3234,7 @@ protected: txnRouter().beginOrContinueTxn( operationContext(), kTxnNumber, TransactionRouter::TransactionActions::kCommit); txnRouter().setDefaultAtClusterTime(operationContext()); - tickSource()->advance(Milliseconds(serverGlobalParams.slowMS + 1)); + tickSource()->advance(Milliseconds(serverGlobalParams.slowMS.load() + 1)); } void assertDurationIs(Microseconds micros) { @@ -3492,16 +3492,16 @@ private: // TEST_F(TransactionRouterMetricsTest, DoesNotLogTransactionsUnderSlowMSThreshold) { - const auto originalSlowMS = serverGlobalParams.slowMS; - const auto originalSampleRate = serverGlobalParams.sampleRate; + const auto originalSlowMS = serverGlobalParams.slowMS.load(); + const auto originalSampleRate = serverGlobalParams.sampleRate.load(); - serverGlobalParams.slowMS = 100; - serverGlobalParams.sampleRate = 1; + serverGlobalParams.slowMS.store(100); + serverGlobalParams.sampleRate.store(1); // Reset the global parameters to their original values after this test exits. ON_BLOCK_EXIT([originalSlowMS, originalSampleRate] { - serverGlobalParams.slowMS = originalSlowMS; - serverGlobalParams.sampleRate = originalSampleRate; + serverGlobalParams.slowMS.store(originalSlowMS); + serverGlobalParams.sampleRate.store(originalSampleRate); }); beginTxnWithDefaultTxnNumber(); @@ -3511,16 +3511,16 @@ TEST_F(TransactionRouterMetricsTest, DoesNotLogTransactionsUnderSlowMSThreshold) } TEST_F(TransactionRouterMetricsTest, LogsTransactionsOverSlowMSThreshold) { - const auto originalSlowMS = serverGlobalParams.slowMS; - const auto originalSampleRate = serverGlobalParams.sampleRate; + const auto originalSlowMS = serverGlobalParams.slowMS.load(); + const auto originalSampleRate = serverGlobalParams.sampleRate.load(); - serverGlobalParams.slowMS = 100; - serverGlobalParams.sampleRate = 1; + serverGlobalParams.slowMS.store(100); + serverGlobalParams.sampleRate.store(1); // Reset the global parameters to their original values after this test exits. ON_BLOCK_EXIT([originalSlowMS, originalSampleRate] { - serverGlobalParams.slowMS = originalSlowMS; - serverGlobalParams.sampleRate = originalSampleRate; + serverGlobalParams.slowMS.store(originalSlowMS); + serverGlobalParams.sampleRate.store(originalSampleRate); }); beginTxnWithDefaultTxnNumber(); @@ -3530,16 +3530,16 @@ TEST_F(TransactionRouterMetricsTest, LogsTransactionsOverSlowMSThreshold) { } TEST_F(TransactionRouterMetricsTest, LogsTransactionsWithAPIParameters) { - const auto originalSlowMS = serverGlobalParams.slowMS; - const auto originalSampleRate = serverGlobalParams.sampleRate; + const auto originalSlowMS = serverGlobalParams.slowMS.load(); + const auto originalSampleRate = serverGlobalParams.sampleRate.load(); - serverGlobalParams.slowMS = 100; - serverGlobalParams.sampleRate = 1; + serverGlobalParams.slowMS.store(100); + serverGlobalParams.sampleRate.store(1); // Reset the global parameters to their original values after this test exits. ON_BLOCK_EXIT([originalSlowMS, originalSampleRate] { - serverGlobalParams.slowMS = originalSlowMS; - serverGlobalParams.sampleRate = originalSampleRate; + serverGlobalParams.slowMS.store(originalSlowMS); + serverGlobalParams.sampleRate.store(originalSampleRate); }); APIParameters::get(operationContext()).setAPIVersion("1"); @@ -3567,16 +3567,16 @@ TEST_F(TransactionRouterMetricsTest, LogsTransactionsWithAPIParameters) { } TEST_F(TransactionRouterMetricsTest, DoesNotLogTransactionsWithSampleRateZero) { - const auto originalSlowMS = serverGlobalParams.slowMS; - const auto originalSampleRate = serverGlobalParams.sampleRate; + const auto originalSlowMS = serverGlobalParams.slowMS.load(); + const auto originalSampleRate = serverGlobalParams.sampleRate.load(); - serverGlobalParams.slowMS = 100; - serverGlobalParams.sampleRate = 0; + serverGlobalParams.slowMS.store(100); + serverGlobalParams.sampleRate.store(0); // Reset the global parameters to their original values after this test exits. ON_BLOCK_EXIT([originalSlowMS, originalSampleRate] { - serverGlobalParams.slowMS = originalSlowMS; - serverGlobalParams.sampleRate = originalSampleRate; + serverGlobalParams.slowMS.store(originalSlowMS); + serverGlobalParams.sampleRate.store(originalSampleRate); }); beginTxnWithDefaultTxnNumber(); |