Re: about fsync in CLOG buffer write - Mailing list pgsql-hackers

From Andres Freund
Subject Re: about fsync in CLOG buffer write
Date
Msg-id 20150902123241.GA25109@alap3.anarazel.de
Whole thread Raw
In response to about fsync in CLOG buffer write  ("张广舟(明虚)" <guangzhou.zgz@alibaba-inc.com>)
Responses Re: about fsync in CLOG buffer write
Re: about fsync in CLOG buffer write
List pgsql-hackers
On 2015-09-10 19:39:59 +0800, 张广舟(明虚) wrote:
> We found there is a fsync call when CLOG buffer
> is written out in SlruPhysicalWritePage(). It is often called when a backend
> needs to check transaction status with SimpleLruReadPage().

That's when there's not enough buffers available some other, and your
case dirty, needs to be written out.

You could try increasing the max (32) in CLOGShmemBuffers() further.

>  ctl->do_fsync is true for CLOG.  Question is, could we just disable fsync
> for CLOG buffer write out here? Is it safe to do so? I understand a
> checkpoint will calls SimpleLruFlush to flush all CLOG buffer at once, and
> the fsync call here (for buffer write out) is not necessary.

No, that'd not be safe. The reason we fsync in SlruPhysicalWritePage()
is that the flush during checkpoint won't necessarily touch those files
at all (as they've been replaced with other buffers in memory).

This could be optimized though - it should be possible to delay the
fsync for slru files that have been evicted from memory till
checkpoint. Using something like ForwardFsyncRequest() except that it
obviously has to be usable for other files than normal relfilenodes.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: synchronous_commit = apply
Next
From: Nikolay Shaplov
Date:
Subject: commitfest does not see my real latest patch