Re: Add pg_file_sync() to adminpack - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add pg_file_sync() to adminpack
Date
Msg-id 20200106064239.GR3598@paquier.xyz
Whole thread Raw
In response to Re: Add pg_file_sync() to adminpack  (Arthur Zakirov <zaartur@gmail.com>)
Responses Re: Add pg_file_sync() to adminpack  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On Mon, Jan 06, 2020 at 03:20:13PM +0900, Arthur Zakirov wrote:
> It isn't case if a file doesn't exist. But if there are no permissions on
> the file:
>
> PANIC:  could not open file "testfile": Permissions denied
> server closed the connection unexpectedly
>
> It could be fixed by implementing a function like pg_file_sync_internal() or
> by making the function fsync_fname_ext() external.

The patch uses stat() to make sure that the file exists and has no
issues.  Though it could be a problem with any kind of TOCTOU-like
issues (looking at you, Windows, for ENOPERM), so I agree that it
would make more sense to use pg_fsync() here with a fd opened first.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: remove some STATUS_* symbols
Next
From: Gavin Flower
Date:
Subject: Re: color by default