summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2021-04-19 10:24:16 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-19 14:44:25 +0000
commitabc2b21e0d47c527c00df30fcf322ff01699877d (patch)
tree57d7ae596a4799b30d421d820479e94a005893bf /jstests
parent46d92ea10a90b8d1330f9e42e90783419598abd8 (diff)
downloadmongo-abc2b21e0d47c527c00df30fcf322ff01699877d.tar.gz
SERVER-55602 Relax non-read-only invariant in WiredTigerKVEngine::makeTemporaryRecordStore when recoverToOplogTimestamp is specified
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/standalone_recover_to_oplog_timestamp.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/jstests/replsets/standalone_recover_to_oplog_timestamp.js b/jstests/replsets/standalone_recover_to_oplog_timestamp.js
new file mode 100644
index 00000000000..d12e9521605
--- /dev/null
+++ b/jstests/replsets/standalone_recover_to_oplog_timestamp.js
@@ -0,0 +1,56 @@
+/**
+ * Test replication recovery as standalone with 'recoverToOplogTimestamp' in read-only mode
+ * (i.e. queryableBackupMode).
+ *
+ * @tags: [
+ * requires_majority_read_concern,
+ * requires_persistence,
+ * requires_replication,
+ * requires_wiredtiger,
+ * ]
+ */
+
+(function() {
+"use strict";
+
+const dbName = "test";
+const collName = jsTestName();
+
+const rst = new ReplSetTest({nodes: 1});
+rst.startSet();
+rst.initiateWithHighElectionTimeout();
+const primary = rst.getPrimary();
+const primaryDB = primary.getDB(dbName);
+
+const recoveryTimestamp = assert.commandWorked(primaryDB.runCommand({ping: 1})).operationTime;
+
+// Hold back the recovery timestamp before doing another write so we have some oplog entries to
+// apply when restart in queryableBackupMode with recoverToOplogTimestamp.
+assert.commandWorked(primaryDB.adminCommand({
+ "configureFailPoint": 'holdStableTimestampAtSpecificTimestamp',
+ "mode": 'alwaysOn',
+ "data": {"timestamp": recoveryTimestamp}
+}));
+
+assert.commandWorked(primaryDB.getCollection(collName).createIndex({a: 1}));
+
+const docs = [{_id: 1, a: 1}];
+const operationTime =
+ assert.commandWorked(primaryDB.runCommand({insert: collName, documents: docs})).operationTime;
+
+rst.stopSet(/*signal=*/null, /*forRestart=*/true);
+
+// Restart as standalone in queryableBackupMode and run replication recovery up to the last insert.
+const primaryStandalone = MongoRunner.runMongod({
+ dbpath: primary.dbpath,
+ noReplSet: true,
+ noCleanData: true,
+ setParameter: {recoverToOplogTimestamp: tojson({timestamp: operationTime})},
+ queryableBackupMode: ""
+});
+
+// Test that the last insert is visible after replication recovery.
+assert.eq(primaryStandalone.getDB(dbName)[collName].find().toArray(), docs);
+
+MongoRunner.stopMongod(primaryStandalone);
+}());