pgsql: Treat directory open failures as hard errors inResetUnloggedRel - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Treat directory open failures as hard errors inResetUnloggedRel
Date
Msg-id E1eM2Q4-0000Ay-1j@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: doc: Turn on generate.consistent.ids parameter