On Wed, Jan 4, 2012 at 3:49 AM, Robert Haas <robertmh...@gmail.com> wrote: > On Fri, Dec 30, 2011 at 11:58 AM, Jeff Janes <jeff.ja...@gmail.com> wrote: >> On 12/29/11, Ants Aasma <ants.aa...@eesti.ee> wrote: >>> Unless I'm missing something, double-writes are needed for all writes, >>> not only the first page after a checkpoint. Consider this sequence of >>> events: >>> >>> 1. Checkpoint >>> 2. Double-write of page A (DW buffer write, sync, heap write) >>> 3. Sync of heap, releasing DW buffer for new writes. >>> ... some time goes by >>> 4. Regular write of page A >>> 5. OS writes one part of page A >>> 6. Crash! >>> >>> Now recovery comes along, page A is broken in the heap with no >>> double-write buffer backup nor anything to recover it by in the WAL. >> >> Isn't 3 the very definition of a checkpoint, meaning that 4 is not >> really a regular write as it is the first one after a checkpoint? > > I think you nailed it.
No, I should have explicitly stated that no checkpoint happens in between. I think the confusion here is because I assumed Kevin described a fixed size d-w buffer in this message: On Thu, Dec 29, 2011 at 6:44 PM, Kevin Grittner <kevin.gritt...@wicourts.gov> wrote: > ... The file is fsync'd (like I said, > hopefully to BBU cache), then each page in the double-write buffer is > written to the normal page location, and that is fsync'd. Once that > is done, the database writes have no risk of being torn, and the > double-write buffer is marked as empty. ... If the double-write buffer survives until the next checkpoint, double-writing only the first write should work just fine. The advantage over current full-page writes is that the write is not into the WAL stream and is done (hopefully) by the bgwriter/checkpointer in the background. -- Ants Aasma -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers