pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Treat directory open failures as hard errors in ResetUnloggedRel
Date: Tue, 05 Dec 2017 01:53:12 +0000
Message-ID: <E1eM2Q4-0000Ay-1j@gemulon.postgresql.org> (raw)

Treat directory open failures as hard errors in ResetUnloggedRelations().

Previously, this code just reported such problems at LOG level and kept
going.  The problem with this approach is that transient failures (e.g.,
ENFILE) could prevent us from resetting unlogged relations to empty,
yet allow recovery to appear to complete successfully.  That seems like
a data corruption hazard large enough to treat such problems as reasons
to fail startup.

For the same reason, treat unlink failures for unlogged files as hard
errors not just LOG messages.  It's a little odd that we did it like that
when file-level errors in other steps (copy_file, fsync_fname) are ERRORs.

The sole case that I left alone is that ENOENT failure on a tablespace
(not database) directory is not an error, though it will now be logged
rather than just silently ignored.  This is to cover the scenario where
a previous DROP TABLESPACE removed the tablespace directory but failed
before removing the pg_tblspc symlink.  I'm not sure that that's very
likely in practice, but that seems like the only real excuse for the
old behavior here, so let's allow for it.  (As coded, this will also
allow ENOENT on $PGDATA/base/.  But since we'll fail soon enough if
that's gone, I don't think we need to complicate this code by
distinguishing that from a true tablespace case.)

Discussion: https://postgr.es/m/21040.1512418508@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8dc3c971a9d6db5ddc9f0a3c11a70308412d66c3

Modified Files
--------------
src/backend/storage/file/reinit.c | 109 ++++++++++++++------------------------
1 file changed, 39 insertions(+), 70 deletions(-)



Message-ID: <E1eM2Q4-0000Ay-1j@gemulon.postgresql.org>
Permalink:  ../E1eM2Q4-0000Ay-1j@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1eM2Q4-0000Ay-1j@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Treat directory open failures as hard errors in ResetUnloggedRel
  In-Reply-To: <E1eM2Q4-0000Ay-1j@gemulon.postgresql.org>
  References: <E1eM2Q4-0000Ay-1j@gemulon.postgresql.org>

* 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