summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2020-11-04 13:53:57 -0500
committerLingzhi Deng <lingzhi.deng@mongodb.com>2020-11-04 13:53:57 -0500
commit2b0d78e836ff4c4ed08212c49e93a02fc20ca669 (patch)
tree6ae234207ef3f43ab08c3c401ea3ab30f23157d8 /jstests
parentf3699db3cf64566a0f87a84cdf9d2f26a6ebff73 (diff)
downloadmongo-2b0d78e836ff4c4ed08212c49e93a02fc20ca669.tar.gz
SERVER-52617: Cache the pointer to the oplog collection before running recoverToOplogTimestamp
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/standalone_recover_to_oplog_timestamp.js54
1 files changed, 54 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..b675eb72add
--- /dev/null
+++ b/jstests/replsets/standalone_recover_to_oplog_timestamp.js
@@ -0,0 +1,54 @@
+/**
+ * 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 = "foo";
+
+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}
+}));
+
+const docs = [{_id: 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);
+}());