diff options
author | Spencer T Brody <spencer@mongodb.com> | 2017-11-14 17:52:12 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2017-11-17 12:05:05 -0500 |
commit | b6235c8418faf541af93e9caacc22b7ed9aed817 (patch) | |
tree | 5eb7416be4d203465cb2f130fc1bb9967c300d0a /jstests/sharding/replication_with_undefined_shard_key.js | |
parent | 368f337eae2aab77b727fb91beb2d2bdd64ac53a (diff) | |
download | mongo-b6235c8418faf541af93e9caacc22b7ed9aed817.tar.gz |
SERVER-31953 Target secondary application of updates and deletes by just _id
Diffstat (limited to 'jstests/sharding/replication_with_undefined_shard_key.js')
-rw-r--r-- | jstests/sharding/replication_with_undefined_shard_key.js | 30 |
1 files changed, 30 insertions, 0 deletions
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 |