From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Thomas Munro <thomas(dot)munro(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-23 06:16:56 |
Message-ID: | CALj2ACVV0FAmgazZ50F-27JSayr4ThXMoGc_N2y=aYbo9wz=0w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Sep 21, 2022 at 4:30 AM Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
>
> 0001 looks reasonable to me.
Thanks for reviewing.
> + errno = 0;
> + rc = pg_pwritev_zeros(fd, pad_to_size);
>
> Do we need to reset errno? pg_pwritev_zeros() claims to set errno
> appropriately.
Right, pg_pwritev_zeros(), (rather pg_pwritev_with_retry() ensures
that pwritev() or pwrite()) sets the correct errno, please see
Thomas's comments [1] as well. Removed it.
> +/*
> + * PWRITEV_BLCKSZ is same as XLOG_BLCKSZ for now, however it may change if
> + * writing more bytes per pg_pwritev_with_retry() call is proven to be more
> + * performant.
> + */
> +#define PWRITEV_BLCKSZ XLOG_BLCKSZ
>
> This seems like something we should sort out now instead of leaving as
> future work. Given your recent note, I think we should just use
> XLOG_BLCKSZ and PGAlignedXLogBlock and add a comment about the performance
> findings with different buffer sizes.
Agreed. Removed the new structure and added a comment.
Another change that I had to do was to allow lseek() even after
pwrite() (via pg_pwritev_zeros()) on Windows in walmethods.c. Without
this, the regression tests start to fail on Windows. And I figured out
that it's not an issue with this patch, it looks like an issue with
pwrite() implementation in win32pwrite.c, see the failure here [2], I
plan to start a separate thread to discuss this.
Please review the attached v4 patch set further.
[1] https://www.postgresql.org/message-id/CA%2BhUKGJKwUrpP0igOFAv5khj3dbHvfWqLzFeo7vtNzDYXv_YZw%40mail.gmail.com
[2] https://github.com/BRupireddy/postgres/tree/use_pwrite_without_lseek_on_windiws
--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v4-0001-Move-pg_pwritev_with_retry-to-file_utils.c.patch | application/x-patch | 5.8 KB |
v4-0002-Use-pg_pwritev_with_retry-instead-of-write-in-wal.patch | application/x-patch | 6.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Sharma | 2022-09-23 06:54:11 | Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions |
Previous Message | Dilip Kumar | 2022-09-23 04:27:48 | Re: making relfilenodes 56 bits |