summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Hu <wei.hu@mongodb.com>2024-09-17 15:45:02 -0700
committerMongoDB Bot <mongo-bot@mongodb.com>2024-09-17 23:26:57 +0000
commitb9b5626076c77f822010eee5b7d21c2d236ef40b (patch)
treed2c87491be6587ef5eed866acc772543e75efc03
parenta5a5cc0ccc2e1339ac1877812e038456f2a6ee76 (diff)
SERVER-94034 Delete oplog_visibility.js and sleepBeforeCommit failpoint (#27120)
GitOrigin-RevId: ad8248d6ab2271e859834ecfac7e0f532e6c2bfa
-rw-r--r--jstests/replsets/oplog_visibility.js127
-rw-r--r--src/mongo/db/storage/BUILD.bazel1
-rw-r--r--src/mongo/db/storage/write_unit_of_work.cpp9
3 files changed, 0 insertions, 137 deletions
diff --git a/jstests/replsets/oplog_visibility.js b/jstests/replsets/oplog_visibility.js
deleted file mode 100644
index 5d1d4180536..00000000000
--- a/jstests/replsets/oplog_visibility.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Test oplog visibility enforcement of primaries and secondaries. This test uses a client to read
- * the oplog while there are concurrent writers. The client copies all the timestamps it sees and
- * verifies a later scan over the range returns the same values.
- */
-import {Thread} from "jstests/libs/parallelTester.js";
-import {ReplSetTest} from "jstests/libs/replsettest.js";
-
-const replTest = new ReplSetTest({
- name: "oplog_visibility",
- nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}],
- settings: {chainingAllowed: true}
-});
-replTest.startSet();
-replTest.initiate();
-
-jsTestLog("Enabling `sleepBeforeCommit` failpoint.");
-for (let node of replTest.nodes) {
- assert.commandWorked(node.adminCommand(
- {configureFailPoint: "sleepBeforeCommit", mode: {activationProbability: 0.01}}));
-}
-
-jsTestLog("Starting concurrent writers.");
-let stopLatch = new CountDownLatch(1);
-let writers = [];
-for (let idx = 0; idx < 2; ++idx) {
- let coll = "coll_" + idx;
- let writer = new Thread(function(host, coll, stopLatch) {
- const conn = new Mongo(host);
- let id = 0;
-
- // Cap the amount of data being inserted to avoid rolling over a 10MiB oplog. It takes
- // ~70,000 "basic" ~150 byte oplog documents to fill a 10MiB oplog. Note this number is
- // for each of two writer threads.
- const maxDocsToInsert = 20 * 1000;
- while (stopLatch.getCount() > 0 && id < maxDocsToInsert) {
- conn.getDB("test").getCollection(coll).insert({_id: id});
- id++;
- }
- jsTestLog({"NumDocsWritten": id});
- }, replTest.getPrimary().host, coll, stopLatch);
-
- writer.start();
- writers.push(writer);
-}
-
-for (let node of replTest.nodes) {
- let testOplog = function(node) {
- let timestamps = [];
-
- let local = node.getDB("local");
- let oplogStart =
- local.getCollection("oplog.rs").find().sort({$natural: -1}).limit(-1).next()["ts"];
- jsTestLog({"Node": node.host, "StartTs": oplogStart});
-
- while (timestamps.length < 1000) {
- // Query with $gte to validate continuinity. Do not add this first record to the
- // recorded timestamps. Its value was already added in the last cursor.
- let cursor = local.getCollection("oplog.rs")
- .find({ts: {$gte: oplogStart}})
- .sort({$natural: 1})
- .tailable(true)
- .batchSize(100);
- assert(cursor.hasNext());
- assert.eq(oplogStart, cursor.next()["ts"]);
-
- // While this method wants to capture 1000 timestamps, the cursor has a batch size
- // of 100 and this loop makes 200 iterations before getting a new cursor from a
- // fresh query. The goal is to exercise getMores, which use different code paths
- // for establishing their oplog reader transactions.
- for (let num = 0; num < 200 && timestamps.length < 1000; ++num) {
- try {
- if (cursor.hasNext() == false) {
- break;
- }
- } catch (exc) {
- break;
- }
- let ts = cursor.next()["ts"];
- timestamps.push(ts);
- oplogStart = ts;
- }
- }
-
- jsTestLog({"Verifying": node.host, "StartTs": timestamps[0], "EndTs": timestamps[999]});
- oplogStart = timestamps[0];
- let cursor =
- local.getCollection("oplog.rs").find({ts: {$gte: oplogStart}}).sort({$natural: 1});
- for (let observedTsIdx = 0; observedTsIdx < timestamps.length; ++observedTsIdx) {
- let observedTs = timestamps[observedTsIdx];
-
- const makeMissingTsMsgFn = function(actualTs) {
- let prev = null;
- let next = null;
- if (observedTsIdx > 0) {
- prev = timestamps[observedTsIdx - 1];
- }
- if (observedTsIdx + 1 < timestamps.length) {
- next = timestamps[observedTsIdx + 1];
- }
-
- return tojson({
- "Missing": actualTs,
- "ObservedTs": observedTs,
- "ObservedIdx": observedTsIdx,
- "PrevObserved": prev,
- "NextObserved": next
- });
- };
-
- assert(cursor.hasNext(), makeMissingTsMsgFn('cursor returned no data'));
- let doc = cursor.next();
- let actualTs = doc["ts"];
- assert.eq(actualTs, observedTs, makeMissingTsMsgFn(actualTs));
- }
- };
-
- jsTestLog({"Testing": node.host});
- testOplog(node);
-}
-jsTestLog("Stopping writers.");
-stopLatch.countDown();
-writers.forEach((writer) => {
- writer.join();
-});
-
-replTest.stopSet();
diff --git a/src/mongo/db/storage/BUILD.bazel b/src/mongo/db/storage/BUILD.bazel
index 19ece94ca97..760d78aaa25 100644
--- a/src/mongo/db/storage/BUILD.bazel
+++ b/src/mongo/db/storage/BUILD.bazel
@@ -536,6 +536,5 @@ mongo_cc_library(
"recovery_unit_base",
"storage_options",
"//src/mongo:base",
- "//src/mongo/util:fail_point",
],
)
diff --git a/src/mongo/db/storage/write_unit_of_work.cpp b/src/mongo/db/storage/write_unit_of_work.cpp
index e9b60cd15b2..2ac3f07046b 100644
--- a/src/mongo/db/storage/write_unit_of_work.cpp
+++ b/src/mongo/db/storage/write_unit_of_work.cpp
@@ -43,14 +43,9 @@
#include "mongo/db/transaction_resources.h"
#include "mongo/platform/compiler.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/duration.h"
-#include "mongo/util/fail_point.h"
-#include "mongo/util/time_support.h"
namespace mongo {
-MONGO_FAIL_POINT_DEFINE(sleepBeforeCommit);
-
WriteUnitOfWork::WriteUnitOfWork(OperationContext* opCtx, OplogEntryGroupType groupOplogEntries)
: _opCtx(opCtx),
_toplevel(opCtx->_ruState == RecoveryUnitState::kNotInUnitOfWork),
@@ -142,10 +137,6 @@ void WriteUnitOfWork::commit() {
opObserver->onBatchedWriteCommit(_opCtx, _groupOplogEntries);
}
if (_toplevel) {
- if (MONGO_unlikely(sleepBeforeCommit.shouldFail())) {
- sleepFor(Milliseconds(100));
- }
-
// Execute preCommit hooks before committing the transaction. This is an opportunity to
// throw or do any last changes before committing.
shard_role_details::getRecoveryUnit(_opCtx)->runPreCommitHooks(_opCtx);