The documentation you quote is correct, if you run the db.fsyncLock() command you will flush all changes to disk and the journal files will be deleted. As soon as you run db.fsyncUnlock() and another write arrives, those journal files will reappear:
Here's a quick example on a test system:
> db.foo.insert({"id" : 1})
Here's what the journal directory looks like:
$ls /usr/local/var/mongodb/journal/ j._1 lsn $
Now, let's lock it up and flush everything to disk:
> db.fsyncLock() { "info" : "now locked against writes, use db.fsyncUnlock() to unlock", "seeAlso" : "http://dochub.mongodb.org/core/fsynccommand", "ok" : 1 }
The journal directory is now empty:
$ls /usr/local/var/mongodb/journal/ $
Unlock, insert:
> db.fsyncUnlock() { "ok" : 1, "info" : "unlock completed" } > db.foo.insert({"id" : 1})
Now we have journal files again:
$ls /usr/local/var/mongodb/journal/ j._2 lsn $
Hence, if you are not locking, flushing the databases to disk and constantly have writes coming in you will always have journal files.
Similarly, when you shut down a mongod
instance cleanly, the journal files will be deleted once the flush to disk has completed successfully.
If you would like to make the journal files smaller, you can look into running with the --smallfiles
option. This will give you 3 x 128MB files rather than 3 x 1GB files.