Thread: Disable WAL backup pages when fsync is off
The following patch disables WAL backup pages when fsync is off. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 Index: src/backend/access/transam/xlog.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v retrieving revision 1.205 diff -c -c -r1.205 xlog.c *** src/backend/access/transam/xlog.c 30 Jun 2005 00:00:50 -0000 1.205 --- src/backend/access/transam/xlog.c 3 Jul 2005 02:52:57 -0000 *************** *** 593,599 **** { /* OK, put it in this slot */ dtbuf[i] = rdt->buffer; ! if (XLogCheckBuffer(rdt, &(dtbuf_lsn[i]), &(dtbuf_xlg[i]))) { dtbuf_bkp[i] = true; rdt->data = NULL; --- 593,601 ---- { /* OK, put it in this slot */ dtbuf[i] = rdt->buffer; ! /* If fsync is off, no need to backup pages. */ ! if (enableFsync && ! XLogCheckBuffer(rdt, &(dtbuf_lsn[i]), &(dtbuf_xlg[i]))) { dtbuf_bkp[i] = true; rdt->data = NULL;
Bruce Momjian <pgman@candle.pha.pa.us> writes: > The following patch disables WAL backup pages when fsync is off. This is a good idea why? regards, tom lane
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > The following patch disables WAL backup pages when fsync is off. > > This is a good idea why? There is no need to write backup pages if fsync is off. Our TODO has: * Turn off after-change writes if fsync is disabled If fsync is off, there is no purpose in writing full pages to WAL Basically, with fsync off, you are saying you don't care about crash recovery, so why write those pages? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Russell Smith wrote: > On Sun, 3 Jul 2005 03:51 pm, Tom Lane wrote: > > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > > The following patch disables WAL backup pages when fsync is off. > > > > This is a good idea why? > > > If it is, why do we write wal at all if fsync is off? Good question. WAL is to recover the file system files in case of a crash. WAL is used in cases where PostgreSQL crashes, but the operating system is still running. WAL brings the file system files back to a consistent state containing all completed transactions. fsync() is for forcing the data to disk so an operating system crash is recoverable. If that isn't happening, the cleanup of partial page writes is hardly important because the system is not consistent. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073