From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, hlinnaka <hlinnaka(at)iki(dot)fi>, Michael Paquier <michael(at)paquier(dot)xyz> |
Subject: | Re: [HACKERS] WAL logging problem in 9.4.3? |
Date: | 2019-11-25 21:50:25 |
Message-ID: | 20191125215025.GA53580@gust.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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(at)leadboat(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2019-11-25 21:56:24 | Re: Allow superuser to grant passwordless connection rights on postgres_fdw |
Previous Message | Laurenz Albe | 2019-11-25 21:34:18 | Re: [Doc] pg_restore documentation didn't explain how to use connection string |