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)
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jakub Wartak <jakub.wartak@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Davinder Singh <davinder.singh@enterprisedb.com>, Dilip Kumar <dilip.kumar@enterprisedb.com>
Date: 2024-12-06T06:01:06Z
Lists: pgsql-hackers
Attachments
- v3-0001-Redirect-to-64-bit-ftruncate-and-lseek-on-Windows.patch (application/x-patch) patch v3-0001
Some better new: 1. _chsize_s does in fact seem to work in an msvcrt.dll build. Thanks to Andres for testing that for me on Windows with a standalone 2 line program on ucrt and msvcrt runtimes. 2. MinGW always has _chsize_s, but it does more or less what I had been proposing already if it can't find the function by the Windows thing like dlsym, so there's no point in writing another thing like that. The test was with a 3G file though so it was the real function. https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-crt/secapi/_chsize_s.c 3. After a long time trying various ways to make it tidy and getting incomprehensible results I eventually realised that precompiled headers were causing strange results on MinGW/Meson builds (on CI), due to fighting over macros with this guy: https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/crt/unistd.h I found it easiest to completely stop it from getting in our way completely, with the attached. Thoughts, anyone? Davinder, Jakub, are you in a position repro the issue and make versions of the patch for the 13, 15 and master branches on top of that?
Commits
-
Fix off_t overflow in pg_basebackup on Windows.
- bd0564f61d37 13.19 landed
- 8f40d46126a0 14.16 landed
- 6b6901a26f56 15.11 landed
- be7489662e77 16.7 landed
- faee3185aafa 17.3 landed
- 970b97eeb8f0 18.0 landed
-
Provide 64-bit ftruncate() and lseek() on Windows.
- 026762dae39d 18.0 landed
- af109e3399b6 17.3 landed
- 0bff6f1da842 16.7 landed
- 70a7a37610f7 15.11 landed
- 1636c5e56ed7 14.16 landed
- d02486cc8e0a 13.19 landed
-
Require ucrt if using MinGW.
- 1758d4244616 18.0 cited