Re: walsender vs. XLogBackgroundFlush during shutdown

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: walsender vs. XLogBackgroundFlush during shutdown
Date: 2019-05-02 14:00:44
Message-ID: CANP8+jJ0cUVsbyORo1mGs0+X=h-qjpX6niRi6BS5=372YpDj=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 1 May 2019 at 01:28, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)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/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-05-02 14:06:42 Inconsistent error message wording for REINDEX CONCURRENTLY
Previous Message Ibrar Ahmed 2019-05-02 13:55:18 Re: pgbench - add option to show actual builtin script code