aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-06-26 09:41:58 +0900
committerMichael Paquier <michael@paquier.xyz>2018-06-26 09:41:58 +0900
commitd08c3d5197fac1f49cedbd8417e685479ad7439a (patch)
tree233e841e8081fb494542898b442e5887f34fd2fc /src
parent322548a8abe225f2cfd6a48e07b99e2711d28ef7 (diff)
downloadpostgresql-d08c3d5197fac1f49cedbd8417e685479ad7439a.tar.gz
postgresql-d08c3d5197fac1f49cedbd8417e685479ad7439a.zip
Correct handling of fsync failures with tar mode of walmethods.c
This file has been missing the fact that it needs to report back to callers a proper failure on fsync calls. I have spotted the one in tar_finish() while Kuntal has spotted the one in tar_close(). Backpatch down to 10 where this code has been introduced. Reported by: Michael Paquier, Kuntal Ghosh Author: Michael Paquier Reviewed-by: Kuntal Ghosh, Magnus Hagander Discussion: https://postgr.es/m/20180625024356.GD1146@paquier.xyz
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/walmethods.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index 331d0e72757..fbfee05a5a6 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -865,7 +865,8 @@ tar_close(Walfile f, WalCloseMethod method)
return -1;
/* Always fsync on close, so the padding gets fsynced */
- tar_sync(f);
+ if (tar_sync(f) < 0)
+ return -1;
/* Clean up and done */
pg_free(tf->pathname);
@@ -896,7 +897,7 @@ tar_finish(void)
return false;
}
- /* A tarfile always ends with two empty blocks */
+ /* A tarfile always ends with two empty blocks */
MemSet(zerobuf, 0, sizeof(zerobuf));
if (!tar_data->compression)
{
@@ -957,7 +958,10 @@ tar_finish(void)
/* sync the empty blocks as well, since they're after the last file */
if (tar_data->sync)
- fsync(tar_data->fd);
+ {
+ if (fsync(tar_data->fd) != 0)
+ return false;
+ }
if (close(tar_data->fd) != 0)
return false;