Incorrect fsync handling in pg_basebackup's tar_finish - Mailing list pgsql-hackers

From Michael Paquier
Subject Incorrect fsync handling in pg_basebackup's tar_finish
Date
Msg-id 20180625024356.GD1146@paquier.xyz
Whole thread Raw
Responses Re: Incorrect fsync handling in pg_basebackup's tar_finish
List pgsql-hackers
Hi all,

I was just looking at the code of pg_basebackup, and noticed that we
don't actually check if the two last empty blocks of any tar file
produced are correctly fsync'd or not:
@@ -957,7 +957,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;
+   }

That looks incorrect to me, hence shouldn't something like the attached
be done?  Magnus and others, any opinions?

Thanks,
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Chapman Flack
Date:
Subject: Is PG built on any C compilers where int division floors?
Next
From: Amit Langote
Date:
Subject: Re: bug with expression index on partition