From: | Davinder Singh <davinder(dot)singh(at)enterprisedb(dot)com> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilip(dot)kumar(at)enterprisedb(dot)com> |
Subject: | Re: Windows pg_basebackup unable to create >2GB pg_wal.tar tarballs ("could not close file: Invalid argument" when creating pg_wal.tar of size ~ 2^31 bytes) |
Date: | 2024-11-27 12:12:26 |
Message-ID: | CAEbAQ-UR3trSyZN_AvQpeuYkFc2Qk3P-PZcfS1TfLY29QwiC-w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Sat, Nov 23, 2024 at 5:14 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Fri, Nov 22, 2024 at 10:55 PM Jakub Wartak
> <jakub(dot)wartak(at)enterprisedb(dot)com> wrote:
> > but with attached _lseeki64 dirty patch I've got success and resulting
> tarball greater than 2^31 too:
>
>
> For ftruncate(), though you didn't see a problem with that, Jacob is
> quite right that it must be able to corrupt stuff, and I retract that
> replacement code I showed earlier, it's not really OK to move the file
> position around. I would like to use _s_chsize() instead, but it
> arrived in msvcr80.dll so I don't think old MinGW can use it. Here's
> a new idea (sketch code not tested):
>
> static inline int
> ftruncate(int fd, pgoff_t length)
> {
> #if defined(_UCRT) || defined(_MSC_VER)
> /* MinGW + UCRT and all supported MSVC versions have this. */
> errno = _s_chsize(fd, length);
> return errno == 0 ? 0 : -1;
> #else
> /* MinGW + ancient msvcrt.dll has only _chsize, limited by off_t
> (long). */
> if (length > LONG_MAX)
> {
> /* A clear error is better than silent corruption. */
> errno = EFBIG;
> return - 1;
> }
> return _chsize(fd, length);
> #endif
> }
>
With the earlier patch, there were some compilation issues on other
platforms, I have modified the patch a little by using some of the changes
from the earlier patch shared by Thomas. Also, I have used the above code
to enable ftruncate() to handle pgoff_t. All the builds and tests on the CI
build <https://cirrus-ci.com/build/6351585205288960> passed except an
already existing build failure in the mingw_cross compiler (not related to
the patch).
--
Regards,
Davinder.
Attachment | Content-Type | Size |
---|---|---|
v2_0001-Bugfix-Windows-pg_basebackup-ability-to-create-2GB-p.patch | application/octet-stream | 3.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2024-11-27 12:26:05 | Re: Difference in dump from original and restored database due to NOT NULL constraints on children |
Previous Message | Kirill Reshke | 2024-11-27 12:04:58 | Re: Add Pipelining support in psql |