From b6235c8418faf541af93e9caacc22b7ed9aed817 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Tue, 14 Nov 2017 17:52:12 -0500 Subject: SERVER-31953 Target secondary application of updates and deletes by just _id --- .../replication_with_undefined_shard_key.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jstests/sharding/replication_with_undefined_shard_key.js (limited to 'jstests/sharding/replication_with_undefined_shard_key.js') diff --git a/jstests/sharding/replication_with_undefined_shard_key.js b/jstests/sharding/replication_with_undefined_shard_key.js new file mode 100644 index 00000000000..8e37c171735 --- /dev/null +++ b/jstests/sharding/replication_with_undefined_shard_key.js @@ -0,0 +1,30 @@ +// Test for SERVER-31953 where secondaries crash when replicating an oplog entry where the document +// identifier in the oplog entry contains a shard key value that contains an undefined value. +(function() { + "use strict"; + + const st = new ShardingTest({mongos: 1, config: 1, shard: 1, rs: {nodes: 2}}); + const mongosDB = st.s.getDB("test"); + const mongosColl = mongosDB.mycoll; + + // Shard the test collection on the "x" field. + assert.commandWorked(mongosDB.adminCommand({enableSharding: mongosDB.getName()})); + assert.commandWorked(mongosDB.adminCommand({ + shardCollection: mongosColl.getFullName(), + key: {x: 1}, + })); + + // Insert a document with a literal undefined value. + assert.writeOK(mongosColl.insert({x: undefined})); + + jsTestLog("Doing writes that generate oplog entries including undefined document key"); + + assert.writeOK(mongosColl.update( + {}, + {$set: {a: 1}}, + {multi: true, writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMs}})); + assert.writeOK( + mongosColl.remove({}, {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMs}})); + + st.stop(); +})(); \ No newline at end of file -- cgit v1.2.1