aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/walsender.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/walsender.c')
-rw-r--r--src/backend/replication/walsender.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 3a0106bc933..e3df5495c33 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -501,11 +501,16 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
pgstat_report_wait_start(WAIT_EVENT_WALSENDER_TIMELINE_HISTORY_READ);
nread = read(fd, rbuf, sizeof(rbuf));
pgstat_report_wait_end();
- if (nread <= 0)
+ if (nread < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read file \"%s\": %m",
path)));
+ else if (nread == 0)
+ ereport(ERROR,
+ (errmsg("could not read file \"%s\": read %d of %zu",
+ path, nread, bytesleft)));
+
pq_sendbytes(&buf, rbuf, nread);
bytesleft -= nread;
}
@@ -2425,13 +2430,20 @@ retry:
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
readbytes = read(sendFile, p, segbytes);
pgstat_report_wait_end();
- if (readbytes <= 0)
+ if (readbytes < 0)
{
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from log segment %s, offset %u, length %lu: %m",
+ errmsg("could not read from log segment %s, offset %u, length %zu: %m",
+ XLogFileNameP(curFileTimeLine, sendSegNo),
+ sendOff, (Size) segbytes)));
+ }
+ else if (readbytes == 0)
+ {
+ ereport(ERROR,
+ (errmsg("could not read from log segment %s, offset %u: read %d of %zu",
XLogFileNameP(curFileTimeLine, sendSegNo),
- sendOff, (unsigned long) segbytes)));
+ sendOff, readbytes, (Size) segbytes)));
}
/* Update state for read */