Re: Unlogged tables cleanup - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Unlogged tables cleanup
Date
Msg-id CAB7nPqTYHE0znrq-g8rfvKQA_rZ2DHSqmsWNKaQ2D08jHEcZEA@mail.gmail.com
Whole thread Raw
In response to Re: Unlogged tables cleanup  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Unlogged tables cleanup  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Wed, Nov 16, 2016 at 11:45 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> The header comment for heap_create_init_fork() says this:
>
> /*
>  * Set up an init fork for an unlogged table so that it can be correctly
>  * reinitialized on restart.  Since we're going to do an immediate sync, we
>  * only need to xlog this if archiving or streaming is enabled.  And the
>  * immediate sync is required, because otherwise there's no guarantee that
>  * this will hit the disk before the next checkpoint moves the redo pointer.
>  */
>
> Your patch causes the code not to match the comment any more.  And the
> comment explains why at the time I wrote this code I thought it was OK
> to have the XLogIsNeeded() test in there, so it clearly needs
> updating.

Indeed I missed this comment block. Please let me suggest the following instead:
 /*
  * Set up an init fork for an unlogged table so that it can be correctly
- * reinitialized on restart.  Since we're going to do an immediate sync, we
- * only need to xlog this if archiving or streaming is enabled.  And the
- * immediate sync is required, because otherwise there's no guarantee that
- * this will hit the disk before the next checkpoint moves the redo pointer.
+ * reinitialized on restart.  An immediate sync is required even if the
+ * page has been logged, because the write did not go through
+ * shared_buffers and therefore a concurrent checkpoint may have moved
+ * the redo pointer past our xlog record.
  */
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Christian Ullrich
Date:
Subject: Re: pgsql: Add putenv support for msvcrt from Visual Studio 2013
Next
From: Peter Eisentraut
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Build HTML documentation using XSLT stylesheets by default