Re: XLogFlush

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: XLogFlush
Date: 2009-08-31 15:48:19
Message-ID: f67928030908310848w32a4d4bcr835a7f54cb2b1f91@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 21, 2009 at 1:18 AM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:

> Maybe this is one of those things that is obvious when someone points
> it out to you, but right now I am not seeing it. If you look at the
> last eight lines of this snippet from XLogFlush, you see that if we
> obtain WriteRqstPtr under the WALInsertLock, then we both write and
> flush up to the highest write request. But if we obtain it under the
> info_lck, then we write up to the highest write request but flush only
> up to our own records flush request. Why the disparate treatment?
> The effect of this seems to be that when WALInsertLock is busy, group
> commits are suppressed.
>

I realized I was misinterpreting this. XLogWrite doesn't just flush up to
WriteRqst.Flush, because fsync doesn't work that way. If it flushes at all
(which I think it always will when invoked from XLogFlush, as otherwise
XLogFlush would not call it), it will flush up to WriteRqst.Write anyway,
even if WriteRqst.Flush is behind. So as long as record <= WriteRqst.Flush
<= WriteRqst.Write, then it doesn't matter exactly what WriteRqst.Flush is.
The problem with group commit on a busy WALInsertLock is that if the
xlogctl->LogwrtRqst.Write does get advanced by someone else, it is almost
surely going to be while we are waiting on the WALWriteLock, and so too late
for us to have discovered it when we previously checked under the protection
of info_lck. We should probably have an else branch on the
LWLockConditionalAcquire so that if it fails, we get the info_lck and check
again for advancement of xlogctl->LogwrtRqst.Write.

But since Simon is doing big changes as part of sync rep, I'll hold off on
doing much experimentation on this until then.

> LWLockRelease(WALInsertLock);
> WriteRqst.Write = WriteRqstPtr;
> WriteRqst.Flush = WriteRqstPtr;
> }
> else
> {
> WriteRqst.Write = WriteRqstPtr;
> WriteRqst.Flush = record;
> }
>

Cheers,

Jeff

In response to

  • XLogFlush at 2009-08-21 08:18:46 from Jeff Janes

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-08-31 15:54:19 Re: autovacuum launcher using InitPostgres
Previous Message Tom Lane 2009-08-31 15:47:53 Re: autovacuum launcher using InitPostgres