Incorrect fsync handling in pg_basebackup's tar_finish

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Incorrect fsync handling in pg_basebackup's tar_finish
Date: 2018-06-25 02:43:56
Message-ID: 20180625024356.GD1146@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
walmethod-fsync.patch text/x-diff 711 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-06-25 02:57:41 Re: bug with expression index on partition
Previous Message Chapman Flack 2018-06-25 02:42:49 Is PG built on any C compilers where int division floors?