> Thinking about a little bit more, I have come across yet another
> possible solution. It is actually *very* simple. Details as follows.
>
> In xact.c:RecordTransactionCommit() there are two FlushBufferPool
> calls. One is for relation files and the other is for pg_log. I add
> sync() right after these FlushBufferPool. It will force any pending
> kernel buffers physically be written onto disk, thus should guarantee
> the ACID of the transaction (see attached code fragment).
Interesting idea. I had proposed this solution long ago. My idea was
to buffer pg_log writes every 30 seconds. Every 30 seconds, do a sync,
then write/sync pg_log. Seemed like a good solution at the time, but
Vadim didn't like it. I think he prefered to do logging, but honestly,
it was over a year ago, and we could have been benefiting from it all
this time.
Second, I had another idea. What if we fsync()'ed a file descriptor
only when we were writing the _last_ dirty buffer for that file. Seems
in many cases this would be a win. I just don't know how hard that is
to figure out. Seems there is no need to fsync() if we still have dirty
buffers around.
-- Bruce Momjian | http://www.op.net/~candle 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,
Pennsylvania19026