Re: walsender vs. XLogBackgroundFlush during shutdown - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: walsender vs. XLogBackgroundFlush during shutdown
Date
Msg-id CANP8+jJ0cUVsbyORo1mGs0+X=h-qjpX6niRi6BS5=372YpDj=w@mail.gmail.com
Whole thread Raw
In response to walsender vs. XLogBackgroundFlush during shutdown  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On Wed, 1 May 2019 at 01:28, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote:
 
Now, this situation is apparently expected, because WalSndWaitForWal()
does this:

    /*
     * If we're shutting down, trigger pending WAL to be written out,
     * otherwise we'd possibly end up waiting for WAL that never gets
     * written, because walwriter has shut down already.
     */
    if (got_STOPPING)
        XLogBackgroundFlush();

but unfortunately that does not actually do anything, because right at
the very beginning XLogBackgroundFlush() does this:

    /* back off to last completed page boundary */
    WriteRqst.Write -= WriteRqst.Write % XLOG_BLCKSZ;

That is, it intentionally ignores the incomplete page, which means the
walsender can't read the record and reach GetFlushRecPtr().

XLogBackgroundFlush() does this since (at least) 2007, so how come we
never had issues with this before?

Yeh, not quite what I originally wrote for that.

I think the confusion is that XLogBackgroundFlush() doesn't do quite what it says.

XLogWrite() kinda does with its "flexible" parameter. So I suggest we do the same on XLogBackgroundFlush() so callers can indicate whether they want it to be flexible or not. 

--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-hackers by date:

Previous
From: Ibrar Ahmed
Date:
Subject: Re: pgbench - add option to show actual builtin script code
Next
From: Tom Lane
Date:
Subject: Inconsistent error message wording for REINDEX CONCURRENTLY