aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/receivelog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_basebackup/receivelog.c')
-rw-r--r--src/bin/pg_basebackup/receivelog.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 406c01bfccc..71f3fb59b7c 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -159,6 +159,9 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir,
{
if (write(f, zerobuf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{
+ /* if write didn't set errno, assume problem is no disk space */
+ if (errno == 0)
+ errno = ENOSPC;
fprintf(stderr,
_("%s: could not pad transaction log file \"%s\": %s\n"),
progname, fn, strerror(errno));
@@ -345,7 +348,9 @@ writeTimeLineHistoryFile(char *basedir, TimeLineID tli, char *filename,
*/
close(fd);
unlink(tmppath);
- errno = save_errno;
+
+ /* if write didn't set errno, assume problem is no disk space */
+ errno = save_errno ? save_errno : ENOSPC;
fprintf(stderr, _("%s: could not write timeline history file \"%s\": %s\n"),
progname, tmppath, strerror(errno));
@@ -354,7 +359,10 @@ writeTimeLineHistoryFile(char *basedir, TimeLineID tli, char *filename,
if (fsync(fd) != 0)
{
+ int save_errno = errno;
+
close(fd);
+ errno = save_errno;
fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"),
progname, tmppath, strerror(errno));
return false;
@@ -1213,6 +1221,9 @@ ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
copybuf + hdr_len + bytes_written,
bytes_to_write) != bytes_to_write)
{
+ /* if write didn't set errno, assume problem is no disk space */
+ if (errno == 0)
+ errno = ENOSPC;
fprintf(stderr,
_("%s: could not write %u bytes to WAL file \"%s\": %s\n"),
progname, bytes_to_write, current_walfile_name,