summaryrefslogtreecommitdiff
path: root/jstests/replsets/read_concern_uninitated_set.js
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2018-05-10 11:14:32 -0400
committerMatthew Russotto <matthew.russotto@10gen.com>2018-05-10 11:14:32 -0400
commit79e63d3d49169fbac6f02f66742bc26a9342ba2c (patch)
tree699cdf1e986c27ee93bcc6abe47e179f0ec490f4 /jstests/replsets/read_concern_uninitated_set.js
parent120e53540fb94330b6594399bdff3ccc99625278 (diff)
downloadmongo-79e63d3d49169fbac6f02f66742bc26a9342ba2c.tar.gz
SERVER-34249 Oplog query on uninitiated replica set node can cause seg fault.
Diffstat (limited to 'jstests/replsets/read_concern_uninitated_set.js')
-rw-r--r--jstests/replsets/read_concern_uninitated_set.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/jstests/replsets/read_concern_uninitated_set.js b/jstests/replsets/read_concern_uninitated_set.js
new file mode 100644
index 00000000000..a590fc374e0
--- /dev/null
+++ b/jstests/replsets/read_concern_uninitated_set.js
@@ -0,0 +1,54 @@
+/**
+ * Test to ensure that specifying non-local read concern with an uninitiated set does not crash
+ * node.
+ */
+(function() {
+ "use strict";
+
+ const rst = new ReplSetTest({nodes: 1});
+ rst.startSet();
+ const localDB = rst.nodes[0].getDB('local');
+ assert.commandWorked(localDB.test.insert({_id: 0}));
+ assert.commandWorked(localDB.runCommand({
+ isMaster: 1,
+ "$clusterTime": {
+ "clusterTime": Timestamp(1, 1),
+ "signature":
+ {"hash": BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId": NumberLong(0)}
+ }
+ }));
+ jsTestLog("Local readConcern on local database should work.");
+ const res = assert.commandWorked(localDB.runCommand(
+ {find: "test", filter: {}, maxTimeMS: 60000, readConcern: {level: "local"}}));
+ assert.eq([{_id: 0}], res.cursor.firstBatch);
+
+ jsTestLog("Majority readConcern should fail with NotYetInitialized.");
+ assert.commandFailedWithCode(
+ localDB.runCommand(
+ {find: "test", filter: {}, maxTimeMS: 60000, readConcern: {level: "majority"}}),
+ ErrorCodes.NotYetInitialized);
+
+ jsTestLog("afterClusterTime readConcern should fail with NotYetInitialized.");
+ assert.commandFailedWithCode(localDB.runCommand({
+ find: "test",
+ filter: {},
+ maxTimeMS: 60000,
+ readConcern: {afterClusterTime: Timestamp(1, 1)}
+ }),
+ ErrorCodes.NotYetInitialized);
+
+ jsTestLog("oplog query should fail with NotYetInitialized.");
+ assert.commandFailedWithCode(localDB.runCommand({
+ find: "oplog.rs",
+ filter: {ts: {$gte: Timestamp(1520004466, 2)}},
+ tailable: true,
+ oplogReplay: true,
+ awaitData: true,
+ maxTimeMS: 60000,
+ batchSize: 13981010,
+ term: 1,
+ readConcern: {afterClusterTime: Timestamp(1, 1)}
+ }),
+ ErrorCodes.NotYetInitialized);
+ rst.stopSet();
+}());