summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-06-01 13:08:46 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-01 19:33:42 +0000
commit092b9da3ddcef9aac0538dfac8955ff23edbc4d4 (patch)
treed1590f724ed19f894afd3cd6b77a70a0f62842de
parentbe44b28afa8503ad0c88c5db9f3e08fef8a30c46 (diff)
downloadmongo-092b9da3ddcef9aac0538dfac8955ff23edbc4d4.tar.gz
SERVER-48510 fix race in StorageTimestampTest::TimestampIndexOplogApplicationOnPrimary
(cherry picked from commit 16d49c9b6496227aae24a0f7ead6dce5053b33d2)
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index 4ed701afffc..ec4c490b483 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -87,6 +87,7 @@
#include "mongo/logv2/log.h"
#include "mongo/stdx/future.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/fail_point.h"
#include "mongo/util/stacktrace.h"
namespace mongo {
@@ -2979,10 +2980,26 @@ public:
auto startBuildOpTime = repl::OpTime(startBuildTs, presentTerm);
UUID indexBuildUUID = UUID::gen();
- auto start = repl::makeStartIndexBuildOplogEntry(
- startBuildOpTime, nss, "field_1", keyPattern, collUUID, indexBuildUUID);
- ASSERT_OK(repl::applyOplogEntryOrGroupedInserts(
- _opCtx, &start, repl::OplogApplication::Mode::kSecondary));
+ // Wait for the index build thread to start the collection scan before proceeding with
+ // checking the catalog and applying the commitIndexBuild oplog entry.
+ // There is a potential race between applying the commitIndexBuild oplog entry and the
+ // transitioning the index build thread's ReplIndexBuildState from kSetup to
+ // kInProgress. This is due to the commit retry logic using the ClockSourceMock, rather
+ // than an actual system clock that advances automatically, through OperationContext's
+ // waitFor() function.
+ {
+ FailPointEnableBlock fpb("hangAfterStartingIndexBuild");
+
+ auto start = repl::makeStartIndexBuildOplogEntry(
+ startBuildOpTime, nss, "field_1", keyPattern, collUUID, indexBuildUUID);
+ ASSERT_OK(repl::applyOplogEntryOrGroupedInserts(
+ _opCtx, &start, repl::OplogApplication::Mode::kSecondary));
+
+ // We cannot use the OperationContext to wait for the thread to reach the fail point
+ // because it also uses the ClockSourceMock.
+ fpb->waitForTimesEntered(/* Interruptible::notInterruptible(), */
+ fpb.initialTimesEntered() + 1);
+ }
{
AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_IS);