diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2019-09-03 08:26:55 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2019-09-03 08:30:21 +0200 |
commit | 396e4afdbcbfd3398415f1a0a29668d6a24a2ddd (patch) | |
tree | 6fd86804b692f0e0a309afdee717620276ee7499 | |
parent | 4e72a8e11e3440b10a10c8de4be2f6664ec41115 (diff) | |
download | postgresql-396e4afdbcbfd3398415f1a0a29668d6a24a2ddd.tar.gz postgresql-396e4afdbcbfd3398415f1a0a29668d6a24a2ddd.zip |
Better error messages for short reads/writes in SLRU
This avoids getting a
Could not read from file ...: Success.
for a short read or write (since errno is not set in that case).
Instead, report a more specific error messages.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/5de61b6b-8be9-7771-0048-860328efe027%402ndquadrant.com
-rw-r--r-- | src/backend/access/transam/slru.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c index 0fbcb4e6fec..e38f9199ddb 100644 --- a/src/backend/access/transam/slru.c +++ b/src/backend/access/transam/slru.c @@ -920,18 +920,29 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) path, offset))); break; case SLRU_READ_FAILED: - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), - errdetail("Could not read from file \"%s\" at offset %u: %m.", - path, offset))); + if (errno) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not access status of transaction %u", xid), + errdetail("Could not read from file \"%s\" at offset %u: %m.", + path, offset))); + else + ereport(ERROR, + (errmsg("could not access status of transaction %u", xid), + errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset))); break; case SLRU_WRITE_FAILED: - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), - errdetail("Could not write to file \"%s\" at offset %u: %m.", - path, offset))); + if (errno) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not access status of transaction %u", xid), + errdetail("Could not write to file \"%s\" at offset %u: %m.", + path, offset))); + else + ereport(ERROR, + (errmsg("could not access status of transaction %u", xid), + errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.", + path, offset))); break; case SLRU_FSYNC_FAILED: ereport(data_sync_elevel(ERROR), |