pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Pandora <yeyukui@qq.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: fsync data directory after DB crash
Date: Wed, 19 Jul 2023 09:41:14 +0900
Message-ID: <ZLcxKpcAU5mK7VG7@paquier.xyz> (raw)
In-Reply-To: <tencent_2B8A7724376F52FB4258043D2B484D95DE09@qq.com>
References: <tencent_2B8A7724376F52FB4258043D2B484D95DE09@qq.com>

On Tue, Jul 18, 2023 at 04:50:25PM +0800, Pandora wrote:
> I found that starting from version 9.5, PostgreSQL will do fsync on
> the entire data directory after DB crash. Here's a question: if I
> have FPW = on, why is this step still necessary?

Yes, see around the call of SyncDataDirectory() in xlog.c:
 * - There might be data which we had written, intending to fsync it, but
 *   which we had not actually fsync'd yet.  Therefore, a power failure in
 *   the near future might cause earlier unflushed writes to be lost, even
 *   though more recent data written to disk from here on would be
 *   persisted.  To avoid that, fsync the entire data directory.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (4+ messages)  latest in thread

Message-ID: <ZLcxKpcAU5mK7VG7@paquier.xyz>
Permalink:  ../ZLcxKpcAU5mK7VG7@paquier.xyz/
Also on:    postgresql.org/message-id/ZLcxKpcAU5mK7VG7@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: michael@paquier.xyz, yeyukui@qq.com
  Subject: Re: fsync data directory after DB crash
  In-Reply-To: <ZLcxKpcAU5mK7VG7@paquier.xyz>
  References: <tencent_2B8A7724376F52FB4258043D2B484D95DE09@qq.com> <ZLcxKpcAU5mK7VG7@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox