From e6396979996d107420aa13dbf65232482edb9abc Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 31 Jan 2011 11:37:23 -0800 Subject: SERVER-2417 wait for file allocator to finish in _deleteDataFiles directoryperdb case --- jstests/disk/preallocate_directoryperdb.js | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 jstests/disk/preallocate_directoryperdb.js (limited to 'jstests') diff --git a/jstests/disk/preallocate_directoryperdb.js b/jstests/disk/preallocate_directoryperdb.js new file mode 100644 index 00000000000..e09cb75f932 --- /dev/null +++ b/jstests/disk/preallocate_directoryperdb.js @@ -0,0 +1,50 @@ +/** + * Test for SERVER-2417 - should preallocate a database file while we are + * dropping its directory in directoryperdb mode. + */ + +var baseDir = "jstests_disk_preallocate_directoryperdb"; +var baseName = "preallocate_directoryperdb" +var baseName2 = "preallocate_directoryperdb2" +var baseName3 = "preallocate_directoryperdb3" +port = allocatePorts( 1 )[ 0 ]; +dbpath = "/data/db/" + baseDir + "/"; + +function checkDb2DirAbsent() { + files = listFiles( dbpath ); +// printjson( files ); + for( var f in files ) { + var name = files[ f ].name; + assert.eq( -1, name.indexOf( dbpath + baseName2 ), "baseName2 dir still present" ); + } +} + +var m = startMongod( "--smallfiles", "--directoryperdb", "--port", port, "--dbpath", dbpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); +db = m.getDB( baseName ); +db2 = m.getDB( baseName2 ); +c = db[ baseName ]; +c2 = db2[ baseName2 ]; +big = new Array( 5000 ).toString(); +for( var i = 0; i < 3000; ++i ) { + c.save( { b:big } ); + c2.save( { b:big } ); + db.getLastError(); +} + +// Due to our write pattern, we expect db2's .3 file to be queued up in the file +// allocator behind db's .3 file at the time db2 is dropped. This will cause +// db2's dir to be recreated until SERVER-2417 is fixed. +db2.dropDatabase(); + +checkDb2DirAbsent(); + +db.dropDatabase(); + +// Try writing a new database, to ensure file allocator is still working. +db3 = m.getDB( baseName3 ); +c3 = db[ baseName3 ]; +c3.save( {} ); +assert( !db3.getLastError() ); +assert.eq( 1, c3.count() ); + +checkDb2DirAbsent(); -- cgit v1.2.1