When does data flush to disk?

445 views
Skip to first unread message

teamcalcf

unread,
Apr 17, 2009, 5:20:51 PM4/17/09
to mongodb-user
When does MongoDB flush data to disk? Right now, I'm trying to run
some load/performance tests on MongoDB, and when I look at the ".0", ".
1" ... ".7" files (right now, the files go up to ".7", and the file
size is around 2 GB), it seems like their last modification time
(according to "ls -l") is simply the time of creation.

Right now, I'm working with a replica pair setup, and I'm trying to
make sure that even if both servers in the pair crash (which I am
simulating by running "kill -9" on both of the mongod processes), that
there is minimal (or, even better, no) data loss when they are
restarted.

I suspect that the answer to my question may be related to the
"oplog" (http://www.mongodb.org/display/DOCS/Replication+Internals),
but I'm not entirely sure. Is the "oplog" flushed to the disk
regularly? Are database operations logged to a temporary file before
they are written to the ".0", ".1" ... ".[number]" files?

Thanks!

Eliot

unread,
Apr 17, 2009, 6:24:11 PM4/17/09
to mongod...@googlegroups.com
Mongo uses mmap extensively. So we write to memory, and things get
periodically written to disk. Everything will get flushed on a
program exit as well.

Currently there is no temporary disk storage for the oplog.

So if you have a replica pair and both servers (physical hardware) go
at the same time, its possible to have some data loss.

Andrey Fedorov

unread,
Jan 6, 2010, 2:37:20 PM1/6/10
to mongod...@googlegroups.com
So what I gather from db/db.cpp:592, by default, everything gets synced to disk every 60 seconds, and is customizable with a --syncdelay parameter, correct?

- Andrey


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en
-~----------~----~----~----~------~----~------~--~---


Michael Schurter

unread,
Jan 6, 2010, 3:21:22 PM1/6/10
to mongod...@googlegroups.com
On Wed, Jan 6, 2010 at 11:37 AM, Andrey Fedorov <anfe...@gmail.com> wrote:
> So what I gather from db/db.cpp:592, by default, everything gets synced to
> disk every 60 seconds, and is customizable with a --syncdelay parameter,
> correct?
> - Andrey

Correct.

Setting syncdelay to 0 just leaves syncing up to the operating system.

Eliot Horowitz

unread,
Jan 6, 2010, 7:06:33 PM1/6/10
to mongod...@googlegroups.com
Correct
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
Reply all
Reply to author
Forward
0 new messages