From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Arthur Zakirov <zaartur(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Add pg_file_sync() to adminpack |
Date: | 2020-01-10 09:50:12 |
Message-ID: | CAHGQGwGzVJMKX7rzFhUUNXJi0_iC2JiYhg9t9VAerD2t+PP_fA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jan 9, 2020 at 10:39 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
>
> On Thu, Jan 9, 2020 at 7:31 AM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> >
> > On Mon, Jan 6, 2020 at 3:42 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> > >
> > > 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.
> >
> > I agree that it's not good for pg_file_sync() to cause a PANIC.
> > I updated the patch so that pg_file_sync() uses fsync_fname_ext()
> > instead of fsync_fname() as Arthur suggested.
> >
> > It's one of ideas to make pg_file_sync() open the file and directly call
> > pg_fsync(). But fsync_fname_ext() has already such code and
> > I'd like to avoid the code duplication.
>
> This looks good to me.
>
> > Attached is the updated version of the patch.
>
> + <row>
> + <entry><function>pg_catalog.pg_file_sync(filename text)</function></entry>
> + <entry><type>boolean</type></entry>
> + <entry>
> + Sync a file or directory
> + </entry>
> + </row>
>
> "Flush to disk" looks better than "sync" here.
I changed the doc that way. Thanks for the review!
> I think that pg_write_server_files should be allowed to call that
> function by default.
But pg_write_server_files users are not allowed to execute
other functions like pg_file_write() by default. So doing that
change only for pg_file_sync() looks strange to me.
Regards,
--
Fujii Masao
Attachment | Content-Type | Size |
---|---|---|
pg_file_sync_v3.patch | application/octet-stream | 7.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Sergei Kornilov | 2020-01-10 10:21:02 | Re: [HACKERS] Block level parallel vacuum |
Previous Message | Pavel Stehule | 2020-01-10 09:38:21 | Re: range_agg |