From 10891b0d812bb17cc023ee968149755a27a7d565 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Wed, 13 Apr 2022 11:13:43 +0200 Subject: [PATCH 4/5] Add errorhandling on file close --- src/bin/pg_basebackup/receivelog.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index ad866a7602..e131e9eb2f 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -142,7 +142,9 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint) { pg_log_error("could not fsync existing write-ahead log file \"%s\": %s", fn, stream->walmethod->getlasterror()); - stream->walmethod->close(f, CLOSE_UNLINK); + if (stream->walmethod->close(f, CLOSE_UNLINK) != 0) + pg_log_error("could not delete write-ahead log file \"%s\": %s", + fn, stream->walmethod->getlasterror()); exit(1); } @@ -207,7 +209,9 @@ close_walfile(StreamCtl *stream, XLogRecPtr pos) { pg_log_error("could not determine seek position in file \"%s\": %s", fn, stream->walmethod->getlasterror()); - stream->walmethod->close(walfile, CLOSE_UNLINK); + if (stream->walmethod->close(walfile, CLOSE_UNLINK) != 0) + pg_log_error("could not delete file \"%s\": %s", + fn, stream->walmethod->getlasterror()); walfile = NULL; pg_free(fn); @@ -313,7 +317,9 @@ writeTimeLineHistoryFile(StreamCtl *stream, char *filename, char *content) /* * If we fail to make the file, delete it to release disk space */ - stream->walmethod->close(f, CLOSE_UNLINK); + if (stream->walmethod->close(f, CLOSE_UNLINK) != 0) + pg_log_error("could not delete timeline history file \"%s\": %s", + histfname, stream->walmethod->getlasterror()); return false; } -- 2.32.0 (Apple Git-132)