Re: Speed up the removal of WAL files

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
Cc: 'Fujii Masao' <masao(dot)fujii(at)gmail(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Speed up the removal of WAL files
Date: 2018-02-21 07:52:50
Message-ID: 20180221075250.GB1632@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 21, 2018 at 07:20:00AM +0000, Tsunakawa, Takayuki wrote:
> Right. Then I thought of doing the following to avoid making a new
> function only for RemoveNonParentXlogFiles() which is similar to
> RemoveXlogFile().
>
> * Add an argument "bool durable" to RemoveXlogFile(). Based on its
> value, RemoveXlogFile() calls either durable_xx() or xx().
>
> * Likewise, add an argument "bool durable" to InstallXLogFileSegment()
> and do the same.
>
> * RemoveNonParentXlogFiles() calls RemoveXlogFile() with
> durable=false. At the end of the function, sync the pg_wal directory
> with fsync_fname().
>
> * RemoveOldXlogFiles() does the same thing. One difference is that it
> passes false to RemoveXlogFile() during recovery (InRecovery == true)
> and true otherwise.

It seems to me that you would reintroduce partially the problems that
1d4a0ab1 has fixed. In short, if a crash happens in the code paths
calling RemoveXlogFile with durable = false before fsync'ing pg_wal,
then a rename has no guarantee to be durable, so you could finish again
with a file that as an old name, but new contents. A crucial thing
which matters for a rename to be durable is that the old file is sync'ed
as well.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tsunakawa, Takayuki 2018-02-21 08:27:40 RE: Speed up the removal of WAL files
Previous Message Michael Paquier 2018-02-21 07:35:50 Re: pg_get_functiondef forgets about most GUC_LIST_INPUT GUCs