--- Ludvig Strigeus <[EMAIL PROTECTED]> wrote: > Dan Kennedy <[EMAIL PROTECTED]> wrote: > > For SQLite 3, the default value of the 'synchronous' pragma > > changed from "NORMAL" to "FULL". IIRC this means the disk is > > synced 3 times instead of 2 for a small transaction. So this > > might be what you're seeing. > > That is indeed the case. The sqlite FULL commit for the journal code works > like this > 1) Write all journal pages > 2) Fsync > 3) Update counter of journal pages in the journal header > 4) Fsync > > Why not do it like this instead: > 1) Check if counter in header matches the file size > 2) Write all journal pages > 3) Update counter of journal pages in the journal header > 4) Fsync
This is pretty much what SQLite does in synchronous=NORMAL mode. SQLite does not assume an fsync() is an atomic operation. If a failure occurs during an fsync(), some pages may be written to disk correctly, some may not be written, and some may have garbage data written to them. So if this happens in synchronous=NORMAL mode, and the journal header is written but some of the page data that follows is garbage, then garbage data can be copied into the main database file. __________________________________ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs