pgsql: Have BufFileSize() ereport() on FileSize() failure. - Mailing list pgsql-committers

From Peter Geoghegan
Subject pgsql: Have BufFileSize() ereport() on FileSize() failure.
Date
Msg-id E1gS8ZE-0003nW-AE@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Have BufFileSize() ereport() on FileSize() failure.

Move the responsibility for checking for and reporting a failure from
the only current BufFileSize() caller, logtape.c, to BufFileSize()
itself.  Code within buffile.c is generally responsible for interfacing
with fd.c to report irrecoverable failures.  This seems like a
convention that's worth sticking to.

Reorganizing things this way makes it easy to make the error message
raised in the event of BufFileSize() failure descriptive of the
underlying problem.  We're now clear on the distinction between
temporary file name and BufFile name, and can show errno, confident that
its value actually relates to the error being reported.  In passing, an
existing, similar buffile.c ereport() + errcode_for_file_access() site
is changed to follow the same conventions.

The API of the function BufFileSize() is changed by this commit, despite
already being in a stable release (Postgres 11).  This seems acceptable,
since the BufFileSize() ABI was changed by commit aa551830421, which
hasn't made it into a point release yet.  Besides, it's difficult to
imagine a third party BufFileSize() caller not just raising an error
anyway, since BufFile state should be considered corrupt when
BufFileSize() fails.

Per complaint from Tom Lane.

Discussion: https://postgr.es/m/26974.1540826748@sss.pgh.pa.us
Backpatch: 11-, where shared BufFiles were introduced.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1a990b207b86967cc323c00adda21fef3b2cd63e

Modified Files
--------------
src/backend/storage/file/buffile.c | 15 +++++++++++----
src/backend/utils/sort/logtape.c   |  4 ----
2 files changed, 11 insertions(+), 8 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Only allow one recovery target setting
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix handling of synchronous replication for stopping WALsenders