[SERVER-12247] Write commands allow un-indexable document to be replicated Created: 03/Jan/14  Updated: 11/Jul/16  Resolved: 13/Jan/14

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Daniel Pasette (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-5290 fail to insert docs with fields too l... Closed
Operating System: ALL
Participants:

 Description   

Passes using legacy write ops, but fails if run with ./buildscripts/smoke.py --use-write-commands

//
// Tests inserting a large indexed key into a replica set
//
 
var rst = new ReplSetTest({ nodes : 2 });
rst.startSet();
rst.initiate();
rst.awaitReplication();
 
var primary = rst.getPrimary();
var secondary = rst.getSecondary();
 
var coll = primary.getCollection("foo.bar");
 
var largeKey = new Array(1024).toString();
coll.ensureIndex({ a : 1 });
coll.insert({ a : largeKey });
var gleObj = coll.getDB().getLastErrorObj();
assert.eq(17280, gleObj.code);
assert.eq(0, coll.count());
 
rst.awaitReplication();
 
var secondaryColl = secondary.getCollection("foo.bar");
assert.eq(0, secondaryColl.count());
 
jsTest.log("DONE!");
rst.stopSet();

And a mulit-version test with a 2.4 primary and latest secondary. In this case, the document is replicated properly, but the invalid document is also inserted into the index even though it reports that it is rejected.

//
// Make sure that a mixed-version replset correctly replicates a document
// with an over-size index key from a 2.4 master to a latest secondary
//
load( './jstests/multiVersion/libs/multi_rs.js' )
 
var oldVersion = "2.4"
var newVersion = "latest"
 
var nodes = { n1 : { binVersion : oldVersion }, n2 : { binVersion : newVersion } }
 
var host = getHostName();
var name = "test";
 
var replTest = new ReplSetTest( { name : name, nodes : nodes } );
 
var nodes = replTest.startSet();
var port = replTest.ports;
replTest.initiate();
 
replTest.awaitReplication();
 
var primary = replTest.getPrimary();
var secondary = replTest.getSecondary();
 
var coll = primary.getCollection("foo.bar");
var largeKey = new Array(2024).toString();
coll.ensureIndex({ a : 1 });
coll.insert({ a : largeKey });
assert.eq(1, coll.count());
 
replTest.awaitReplication();
 
var secondaryColl = secondary.getCollection("foo.bar");
assert.eq(1, secondaryColl.count());
printjson(secondaryColl.validate().keysPerIndex);
assert.eq(0, secondaryColl.find().hint('a_1').itcount());
 
jsTest.log("DONE!");
replTest.stopSet();



 Comments   
Comment by Githook User [ 13/Jan/14 ]

Author:

{u'username': u'monkey101', u'name': u'Dan Pasette', u'email': u'dan@10gen.com'}

Message: SERVER-12247 Write commands allow un-indexable document to be replicated
Branch: master
https://github.com/mongodb/mongo/commit/63ee8470a45ac3f25d80a10dc2256dc5d4a7ccbb

Generated at Thu Feb 08 03:28:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.