From 680651938e30b5208a73b9d76813a5880af4ab54 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 18 Jun 2019 14:27:53 +0200 Subject: [PATCH 1/2] 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. --- src/backend/access/transam/slru.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c index 2dbc65b125..315c0612e6 100644 --- a/src/backend/access/transam/slru.c +++ b/src/backend/access/transam/slru.c @@ -923,15 +923,19 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) 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))); + errno == 0 + ? errdetail("Short read from file \"%s\" at offset %u.", path, offset) + : errdetail("Could not read from file \"%s\" at offset %u: %m.", + 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))); + errno == 0 + ? errdetail("Short write to file \"%s\" at offset %u.", path, offset) + : errdetail("Could not write to file \"%s\" at offset %u: %m.", + path, offset))); break; case SLRU_FSYNC_FAILED: ereport(data_sync_elevel(ERROR), -- 2.22.0