/* @file : jstests/fsync_lock_read_secondaries.js * * SERVER 4243 : If there is a pending write due to an fsync lock, all reads are blocked * * This test validates part of SERVER-4243 ticket. Allow reading on secondaries with fsyncLock * mode enabled. Previously oplog application would cause blocking. * The corresponding commit : * https://github.com/mongodb/mongo/commit/73aa870d129bd7d51de946b91c16cc056aaacbc7 */ /* * 1) Create a replica set. * 2) Add some documents to master. * 3) Wait until the secondary nodes are in state "SECONDARY". * 4) Set slaveOk on secondary. * 5) Take the fsync lock on a secondary. This will stop replication. * 6) Insert some more documents to master. * 7) Expect to be able to read from the secondary; the count of documents should * be equal to the number of documents added in step 2. * 8) Release the fsync lock. This will resume replication. * 9) Soon, the secondary should be applying the oplog again, which we should * witness as an increase in the count of documents stored on the secondary. */ (function() { "use strict"; // Load utility methods for replica set tests load("jstests/replsets/rslib.js"); var replTest = new ReplSetTest({name: 'testSet', nodes: 2, oplogSize: 5}); // Start each mongod in the replica set. Returns a list of nodes var nodes = replTest.startSet(); // This will wait for initiation replTest.initiate(); var master = replTest.getPrimary(); var ret = master.getDB("admin").fsyncLock(); if (!ret.ok) { assert.commandFailedWithCode(ret, ErrorCodes.CommandNotSupported); jsTestLog("Storage Engine does not support fsyncLock, so bailing"); return; } master.getDB("admin").fsyncUnlock(); var docNum = 100; for(var i=0; i 100 }, "count of documents stored on the secondary did not increase"); replTest.stopSet(); }());