Re: Incorrect fsync handling in pg_basebackup's tar_finish

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Incorrect fsync handling in pg_basebackup's tar_finish
Date: 2018-06-25 08:57:29
Message-ID: CABUevEw2_mG2Ma4Xhk2BkuXq3d67aGPRfBcMxUMaK5EvKcyzow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 25, 2018 at 4:43 AM, Michael Paquier <michael(at)paquier(dot)xyz>
wrote:

> 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?
>

Yup, that seems like an issue and a correct fix to me.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2018-06-25 09:08:41 Re: PATCH: backtraces for error messages
Previous Message Kyotaro HORIGUCHI 2018-06-25 08:31:13 Re: [bug fix] ECPG: freeing memory for pgtypes crashes on Windows