summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
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 17:32:35 +0000
commit16d49c9b6496227aae24a0f7ead6dce5053b33d2 (patch)
treefe2f1596bbece1bd7dcd4c791759a383906d4266 /src/mongo/dbtests
parentf95ee0caa794a62eb37cf3537001853b4b78a0ec (diff)
downloadmongo-16d49c9b6496227aae24a0f7ead6dce5053b33d2.tar.gz
SERVER-48510 fix race in StorageTimestampTest::TimestampIndexOplogApplicationOnPrimary
Diffstat (limited to 'src/mongo/dbtests')
-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 667a46350df..3181b1cb0c0 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 {
@@ -2762,10 +2763,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);