Permalink
Browse files

SERVER-12842 do not add filterSet to explain if solution is not avail…

…able in single solution runner
  • Loading branch information...
1 parent 03b5eae commit 0b4ee727db118d01f28cb046c23068d4961990fe @benety benety committed Feb 22, 2014
@@ -1,69 +0,0 @@
-
-doTest = function( signal ) {
- // Test add node
-
- var replTest = new ReplSetTest( {name: 'testSet', nodes: 0, host:"localhost"} );
-
- var first = replTest.add();
-
- // Initiate replica set
- assert.soon(function() {
- var res = first.getDB("admin").runCommand({replSetInitiate: {
- _id : 'testSet',
- members : [{_id : 0, host : "localhost:"+replTest.ports[0]}]
- }
- });
- return res['ok'] == 1;
- });
-
- // Get status
- assert.soon(function() {
- var result = first.getDB("admin").runCommand({replSetGetStatus: true});
- return result['ok'] == 1;
- });
-
- db = replTest.getMaster().getDB( "test");
- db.foo.insert( { x : 1} );
- db.foo.ensureIndex( { x : 1 } );
-
- // Start a second node
- var second = replTest.add();
-
- // Add the second node.
- // This runs the equivalent of rs.add(newNode);
- print("calling add again");
- try {
- replTest.reInitiate();
- }
- catch(e) {
- print(e);
- }
-
- print("try to change to localhost to "+getHostName());
- var master = replTest.getMaster();
-
- var config = master.getDB("local").system.replset.findOne();
- config.version++;
- config.members.forEach(function(m) {
- m.host = m.host.replace("localhost", getHostName());
- print(m.host);
- });
- printjson(config);
-
- print("trying reconfig that shouldn't work");
- var result = master.getDB("admin").runCommand({replSetReconfig: config});
- assert.eq(result.ok, 0, tojson(result));
- assert.eq(result.code, 13645, tojson(result));
-
- replTest.awaitReplication();
-
- hashes = replTest.getHashes( "test" );
- printjson( hashes );
- for ( i=0; i<hashes.slaves.length; i++ ) {
- assert.eq( hashes.master.collections.foo , hashes.slaves[i].collections.foo );
- }
-
- replTest.stopSet( signal );
-}
-
-doTest( 15 );
@@ -0,0 +1,32 @@
+// Tests adding node to replica set with profiling enabled.
+// Verifies that the oplog replay hack is compatible with
+// the profiling option.
+// One of the ways to exercise the oplog replay hack is to
+// add a new node to an existing active replica set.
+
+// Initialize a single node replica set where
+// the only node is running at a profiling level of 2.
+var collectionName = 'jstests_replsetadd_profile';
+
+var replTest = new ReplSetTest({name: 'ReplSetAddProfileTestSet',
+ nodes: [{profile: 2}],
+ host: "localhost"});
+replTest.startSet();
+replTest.initiate();
+var master = replTest.getMaster();
+var masterCollection = master.getDB('test').getCollection(collectionName);
+masterCollection.save({a: 1});
+
+// Add a new node with no profiling level.
+var newNode = replTest.add();
+replTest.reInitiate();
+
+// Allow documents to propagate to new replica set member.
+replTest.awaitReplication();
+
+var newNodeCollection = newNode.getDB('test').getCollection(collectionName);
+assert.eq(1, newNodeCollection.find({a: 1}).itcount(),
+ 'expect documents to be present in slave after replication');
+
+var signal = 15;
+replTest.stopSet( signal );
@@ -112,7 +112,12 @@ namespace mongo {
}
(*explain)->setNScannedObjectsAllPlans((*explain)->getNScannedObjects());
(*explain)->setNScannedAllPlans((*explain)->getNScanned());
- (*explain)->setIndexFilterApplied(_solution->indexFilterApplied);
+
+ // _solution could be NULL in certain cases such as when QueryOption_OplogReplay
+ // is enabled in the query flags.
+ if (_solution) {
+ (*explain)->setIndexFilterApplied(_solution->indexFilterApplied);
+ }
}
else if (NULL != planInfo) {
if (NULL == _solution.get()) {
@@ -605,6 +605,31 @@ namespace QueryTests {
}
};
+ class OplogReplayExplain : public ClientBase {
+ public:
+ ~OplogReplayExplain() {
+ client().dropCollection( "unittests.querytests.OplogReplayExplain" );
+ }
+ void run() {
+ const char *ns = "unittests.querytests.OplogReplayExplain";
+ insert( ns, BSON( "ts" << 0 ) );
+ insert( ns, BSON( "ts" << 1 ) );
+ insert( ns, BSON( "ts" << 2 ) );
+ auto_ptr< DBClientCursor > c = client().query(
+ ns, QUERY( "ts" << GT << 1 ).hint( BSON( "$natural" << 1 ) ).explain(),
+ 0, 0, 0, QueryOption_OplogReplay );
+ ASSERT( c->more() );
+
+ // Check number of results and filterSet flag in explain.
+ // filterSet is not available in oplog replay mode.
+ BSONObj explainObj = c->next();
+ ASSERT_EQUALS( 1, explainObj.getIntField( "n" ) );
+ ASSERT_FALSE( explainObj.hasField( "filterSet" ) );
+
+ ASSERT( !c->more() );
+ }
+ };
+
class BasicCount : public ClientBase {
public:
~BasicCount() {
@@ -1538,6 +1563,7 @@ namespace QueryTests {
add< TailableQueryOnId >();
add< OplogReplayMode >();
add< OplogReplaySlaveReadTill >();
+ add< OplogReplayExplain >();
add< ArrayId >();
add< UnderscoreNs >();
add< EmptyFieldSpec >();

0 comments on commit 0b4ee72

Please sign in to comment.