pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: hlinnaka <hlinnaka@iki.fi>
Cc: Michael Paquier <michael@paquier.xyz>
Subject: Re: [HACKERS] WAL logging problem in 9.4.3?
Date: Mon, 25 Nov 2019 16:50:25 -0500
Message-ID: <20191125215025.GA53580@gust.leadboat.com> (raw)
In-Reply-To: <CA+TgmoYzjPYCyU5o6XQ1B6JGhYM8MXGNGxhPpz=tFYdHEHGeGA@mail.gmail.com>
References: <CA+TgmoYzTPpxvPUUs_ALW1YYNxV6mCrj6zwqnaN6FqdNc1JUzw@mail.gmail.com>
	<20191105225335.GA395764@rfd.leadboat.com>
	<20191118045434.GA1173436@rfd.leadboat.com>
	<20191121.160107.1405593316918593372.horikyota.ntt@gmail.com>
	<20191123212136.GA41522@gust.leadboat.com>
	<CA+TgmoYzjPYCyU5o6XQ1B6JGhYM8MXGNGxhPpz=tFYdHEHGeGA@mail.gmail.com>

On Mon, Nov 25, 2019 at 03:58:14PM -0500, Robert Haas wrote:
> On Sat, Nov 23, 2019 at 4:21 PM Noah Misch <noah@leadboat.com> wrote:
> > I noticed an additional defect:
> >
> > BEGIN;
> > CREATE TABLE t (c) AS SELECT 1;
> > CHECKPOINT; -- write and fsync the table's one page
> > TRUNCATE t; -- no WAL
> > COMMIT; -- no FPI, just the commit record
> >
> > If we crash after the COMMIT and before the next fsync or OS-elected sync of
> > the table's file, the table will stay on disk with its pre-TRUNCATE content.
> 
> Shouldn't the TRUNCATE be triggering an fsync() to happen before
> COMMIT is permitted to complete?

With wal_skip_threshold=0, you do get an fsync().  The patch tries to avoid
at-commit fsync of small files by WAL-logging file contents instead.  However,
the patch doesn't WAL-log enough to handle files that decreased in size.

> You'd have the same problem if the
> TRUNCATE were replaced by INSERT, unless fsync() happens in that case.

I think an insert would be fine.  You'd get an FPI record for the relation's
one page, which fully reproduces the relation.





view thread (244+ messages)  latest in thread

Message-ID: <20191125215025.GA53580@gust.leadboat.com>
Permalink:  ../20191125215025.GA53580@gust.leadboat.com/
Also on:    postgresql.org/message-id/20191125215025.GA53580@gust.leadboat.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: noah@leadboat.com, robertmhaas@gmail.com, horikyota.ntt@gmail.com, 9erthalion6@gmail.com, andrew.dunstan@2ndquadrant.com, hlinnaka@iki.fi, michael@paquier.xyz
  Subject: Re: [HACKERS] WAL logging problem in 9.4.3?
  In-Reply-To: <20191125215025.GA53580@gust.leadboat.com>

* 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