Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?

Поиск
Список
Период
Сортировка
Искать
От
Nathan Bossart
Тема
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?
Дата
Msg-id
20220926212704.GA1342110@nathanxps13
Ответ на
Список
Дерево обсуждения
Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Nathan Bossart <nathandbossart@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Alvaro Herrera <alvherre@alvh.no-ip.org>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Julien Rouhaud <rjuju123@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Alvaro Herrera <alvherre@alvh.no-ip.org>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Thomas Munro <thomas.munro@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Andres Freund <andres@anarazel.de>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? John Naylor <john.naylor@enterprisedb.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Michael Paquier <michael@paquier.xyz>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? John Naylor <john.naylor@enterprisedb.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes? Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
On Mon, Sep 26, 2022 at 08:33:53PM +0530, Bharath Rupireddy wrote:
> Irrespective of what Windows does with file pointers in WriteFile(),
> should we add lseek(SEEK_SET) in our own pwrite()'s implementation,
> something like [5]? This is rather hackish without fully knowing what
> Windows does internally in WriteFile(), but this does fix inherent
> issues that our pwrite() callers (there are quite a number of places
> that use pwrite() and presumes file pointer doesn't change on Windows)
> may have on Windows. See the regression tests passing [6] with the fix
> [5].

I think so.  I don't see why we would rather have each caller ensure
pwrite() behaves as documented.

> +       /*
> +        * On Windows, it is found that WriteFile() changes the file
> pointer and we
> +        * want pwrite() to not change. Hence, we explicitly reset the
> file pointer
> +        * to beginning of the file.
> +        */
> +       if (lseek(fd, 0, SEEK_SET) != 0)
> +       {
> +               _dosmaperr(GetLastError());
> +               return -1;
> +       }
> +
>         return result;
>  }

Why reset to the beginning of the file?  Shouldn't we reset it to what it
was before the call to pwrite()?

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com


В списке pgsql-hackers по дате отправления
От: Nikita Malakhov
Дата:
Сообщение: Re: Pluggable toaster
От: David Rowley
Дата:
FAQ