I was wondering, when we start to reuse a WAL file, do we know that all
dirty buffers modified in that WAL file have been flushed to disk?  Do
we fsync() dirty buffers at time of checkpoint, and do we also make sure
that buffers we wrote to disk and later reused before the checkpoint
also made it to disk?

My point is that writing it to the kernel doesn't guarantee it made it
to disk.

I see the WAL records being fsync'ed in xlog.c but I don't see the
buffer pages being fsynced.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 18 Dec 2001 22:03:39 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
checkpoint reliability
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I was wondering, when we start to reuse a WAL file, do we know that all
> dirty buffers modified in that WAL file have been flushed to disk?

Yes.  At least two checkpoints ago, in fact.

			regards, tom lane

Tue, 18 Dec 2001 23:06:34 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: checkpoint reliability 
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I was wondering, when we start to reuse a WAL file, do we know that all
> > dirty buffers modified in that WAL file have been flushed to disk?
> 
> Yes.  At least two checkpoints ago, in fact.

So when we decide to reuse a shared memory buffer and write it to disk,
do we fsync it, or do we run a file sync() to force all dirty buffers to
disk?


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 18 Dec 2001 23:10:20 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: checkpoint reliability
Tom Lane wrote:
> 
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I was wondering, when we start to reuse a WAL file, do we know that all
> > dirty buffers modified in that WAL file have been flushed to disk?
> 
> Yes.  At least two checkpoints ago, in fact.

Isn't the following what Bruce asked ?

/*
 *	mdsync() -- Sync storage.
 *
 */
int
mdsync()
{
	sync();
	if (IsUnderPostmaster)
		sleep(2);
	sync();
	return SM_SUCCESS;
}

regards,
Hiroshi Inoue

Wed, 19 Dec 2001 13:33:49 +0900
Hiroshi Inoue <Inoue@tpf.co.jp>
Re: checkpoint reliability
> Tom Lane wrote:
> > 
> > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > > I was wondering, when we start to reuse a WAL file, do we know that all
> > > dirty buffers modified in that WAL file have been flushed to disk?
> > 
> > Yes.  At least two checkpoints ago, in fact.
> 
> Isn't the following what Bruce asked ?
> 
> /*
>  *	mdsync() -- Sync storage.
>  *
>  */
> int
> mdsync()
> {
> 	sync();
> 	if (IsUnderPostmaster)
> 		sleep(2);
> 	sync();
> 	return SM_SUCCESS;
> }

Oh, yes.  That is it. I couldn't find out how we were sure our pages
that we had written to the kernel were actually on disk before we
started reusing the WAL files.

Thanks.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 18 Dec 2001 23:34:36 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: checkpoint reliability