2011-11-15 03:29:44 +01:00
|
|
|
|
2012-06-04 17:45:29 +02:00
|
|
|
function debug( msg ) {
|
|
|
|
print( "fsync2: " + msg );
|
|
|
|
}
|
|
|
|
|
2012-06-10 15:53:23 +02:00
|
|
|
var loops = 200;
|
|
|
|
if ( db.getSisterDB("local").slaves.count() > 0 ) {
|
|
|
|
// replication can cause some write locks on local
|
|
|
|
// therefore this test is flaky with replication on
|
|
|
|
loops = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-04 17:37:56 +02:00
|
|
|
function doTest() {
|
|
|
|
db.fsync2.drop();
|
2014-03-03 17:17:44 +01:00
|
|
|
// Make write ops asynchronous so the test won't hang when in fsync lock mode.
|
|
|
|
db.getMongo().forceWriteMode('legacy');
|
|
|
|
|
2012-06-04 17:37:56 +02:00
|
|
|
db.fsync2.save( {x:1} );
|
|
|
|
|
|
|
|
d = db.getSisterDB( "admin" );
|
|
|
|
|
|
|
|
assert.commandWorked( d.runCommand( {fsync:1, lock: 1 } ) );
|
2012-06-04 17:45:29 +02:00
|
|
|
|
|
|
|
debug( "after lock" );
|
2012-06-04 17:37:56 +02:00
|
|
|
|
2012-06-10 15:53:23 +02:00
|
|
|
|
|
|
|
for ( var i=0; i<loops; i++) {
|
2012-06-04 17:45:29 +02:00
|
|
|
debug( "loop: " + i );
|
2012-06-04 17:37:56 +02:00
|
|
|
assert.eq(1, db.fsync2.count());
|
2012-06-04 17:45:29 +02:00
|
|
|
sleep(100);
|
2012-06-04 17:37:56 +02:00
|
|
|
}
|
|
|
|
|
2012-06-04 17:45:29 +02:00
|
|
|
debug( "about to save" );
|
2012-06-04 17:37:56 +02:00
|
|
|
db.fsync2.save( {x:1} );
|
2012-06-04 17:45:29 +02:00
|
|
|
debug( "save done" );
|
2012-06-04 17:37:56 +02:00
|
|
|
|
|
|
|
m = new Mongo( db.getMongo().host );
|
|
|
|
|
|
|
|
// Uncomment once SERVER-4243 is fixed
|
|
|
|
//assert.eq(1, m.getDB(db.getName()).fsync2.count());
|
|
|
|
|
2015-03-26 15:03:29 +01:00
|
|
|
assert( m.getDB("admin").fsyncUnlock().ok );
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2012-06-04 17:37:56 +02:00
|
|
|
assert.eq( 2, db.fsync2.count() );
|
|
|
|
|
2012-02-03 15:28:35 +01:00
|
|
|
}
|
2011-11-15 03:29:44 +01:00
|
|
|
|
2012-06-04 17:37:56 +02:00
|
|
|
if (!jsTest.options().auth) { // SERVER-4243
|
|
|
|
doTest();
|
2012-02-03 15:28:35 +01:00
|
|
|
}
|