pgsql: Have BufFileSize() ereport() on FileSize() failure.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Have BufFileSize() ereport() on FileSize() failure.
Date: 2018-11-28 22:44:24
Message-ID: E1gS8ZE-0003nW-AE@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2018-11-29 00:15:02 pgsql: Fix handling of synchronous replication for stopping WAL senders
Previous Message Peter Eisentraut 2018-11-28 17:14:10 Re: pgsql: Integrate recovery.conf into postgresql.conf