Skip to content
Snippets Groups Projects
Commit 6ef12164 authored by Peter Eisentraut's avatar Peter Eisentraut
Browse files

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: default avatarMichael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/5de61b6b-8be9-7771-0048-860328efe027%402ndquadrant.com
parent 5380719f
No related branches found
No related tags found
No related merge requests found
......@@ -920,18 +920,29 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
path, offset)));
break;
case SLRU_READ_FAILED:
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:
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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment