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

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?
Date: 2022-09-27 09:30:22
Message-ID: CA+hUKG+ZiAF1Sxik9+biUJS2phb3umR0DWdh-JpvYGf_RWa_wQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 27, 2022 at 6:43 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> On Tue, Sep 27, 2022 at 3:08 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> >
> > I don't think so, that's an extra kernel call. I think I'll just have
> > to revert part of my recent change that removed the pg_ prefix from
> > those function names in our code, and restore the comment that warns
> > you about the portability hazard (I thought it went away with HP-UX
> > 10, where we were literally calling lseek() before every write()).
> > The majority of users of these functions don't intermix them with
> > calls to read()/write(), so they don't care about the file position,
> > so I think it's just something we'll have to continue to be mindful of
> > in the places that do.
>
> Yes, all of the existing pwrite() callers don't care about the file
> position, but the new callers such as the actual idea and patch
> proposed here in this thread cares.
>
> Is this the commit cf112c122060568aa06efe4e6e6fb9b2dd4f1090 part of
> which [1] you're planning to revert?

Yeah, just the renaming parts of that. The lseek()-based emulation is
definitely not coming back. Something like the attached.

Attachment Content-Type Size
0001-Restore-pg_pread-and-friends.txt text/plain 17.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Benjamin Coutu 2022-09-27 09:39:31 Re: Insertion Sort Improvements
Previous Message houzj.fnst@fujitsu.com 2022-09-27 09:28:18 RE: A doubt about a newly added errdetail