Skip to content

Commit 396e4af

Browse files
committed
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
1 parent 4e72a8e commit 396e4af

File tree

1 file changed

+21
-10
lines changed
  • src/backend/access/transam

1 file changed

+21
-10
lines changed

src/backend/access/transam/slru.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -920,18 +920,29 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
920920
path, offset)));
921921
break;
922922
case SLRU_READ_FAILED:
923-
ereport(ERROR,
924-
(errcode_for_file_access(),
925-
errmsg("could not access status of transaction %u", xid),
926-
errdetail("Could not read from file \"%s\" at offset %u: %m.",
927-
path, offset)));
923+
if (errno)
924+
ereport(ERROR,
925+
(errcode_for_file_access(),
926+
errmsg("could not access status of transaction %u", xid),
927+
errdetail("Could not read from file \"%s\" at offset %u: %m.",
928+
path, offset)));
929+
else
930+
ereport(ERROR,
931+
(errmsg("could not access status of transaction %u", xid),
932+
errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
928933
break;
929934
case SLRU_WRITE_FAILED:
930-
ereport(ERROR,
931-
(errcode_for_file_access(),
932-
errmsg("could not access status of transaction %u", xid),
933-
errdetail("Could not write to file \"%s\" at offset %u: %m.",
934-
path, offset)));
935+
if (errno)
936+
ereport(ERROR,
937+
(errcode_for_file_access(),
938+
errmsg("could not access status of transaction %u", xid),
939+
errdetail("Could not write to file \"%s\" at offset %u: %m.",
940+
path, offset)));
941+
else
942+
ereport(ERROR,
943+
(errmsg("could not access status of transaction %u", xid),
944+
errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
945+
path, offset)));
935946
break;
936947
case SLRU_FSYNC_FAILED:
937948
ereport(data_sync_elevel(ERROR),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy