git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] compat/mingw: implement POSIX-style atomic renames
@ 2024-10-23 15:04 Patrick Steinhardt
  2024-10-23 15:04 ` [PATCH 1/3] compat/mingw: share file handles created via `CreateFileW()` Patrick Steinhardt
                   ` (5 more replies)
  0 siblings, 6 replies; 44+ messages in thread
From: Patrick Steinhardt @ 2024-10-23 15:04 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

Hi,

so after chatting with Johannes recently I decided to have another stab
at the failures we've seen on Windows with the reftable backend. A quick
refresher: reftables use a central "tables.lock" file that gets updated
via renames such that the update itself is atomic. This causes issues on
Windows when there are many concurrent readers/writers because Windows
does not allow you to rename a file over another file that is held open
by another process by default. This issue is surfaced by t0610, where we
spawn a 100 concurrent git-update-ref(1) processes.

This patch series aims to fix the issue on Windows by implementing
POSIX-style atomic renames. The first two patches refactor the code such
that we use `FILE_SHARE_DELETE` to open files, which allows other
processes to delete the file even while we have an open handle. This
sharing mode is also important in the context of renames, which are
treated like a deletion of the replaced file. The third patch then
reimplements renames via `SetFileAttributesByHandle(FileRenameInfoEx)`,
which has a flag `FILE_RENAME_FLAG_POSIX_SEMANTICS`. When set, Windows
allows us to replace files during a rename which still have an open
handle.

There's one catch: this is only supported in Windows 10 and newer. On
one hand this means that we have to provide the required definitions
ourselves, as we cannot bump the Windows SDK version. On the other hand
we also have to support the case where older Windows versions now fail
at runtime due to `FileRenameInfoEx` being unsupported. But overall this
isn't too bad, I'd say. Johannes has also kindly tested the fallback
logic for me on Windows 8.1.

With these changes t0610 now passes on my Windows 10 machine, but this
may also have a positive impact on other parts of Git where we might
have previously failed.

Thanks!

Patrick

Patrick Steinhardt (3):
  compat/mingw: share file handles created via `CreateFileW()`
  compat/mingw: allow deletion of most opened files
  compat/mingw: support POSIX semantics for atomic renames

 compat/mingw.c             | 146 +++++++++++++++++++++++++++++++++++--
 t/t0610-reftable-basics.sh |   8 +-
 2 files changed, 145 insertions(+), 9 deletions(-)
-- 
2.47.0.118.gfd3785337b.dirty


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2024-11-06 12:09 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 15:04 [PATCH 0/3] compat/mingw: implement POSIX-style atomic renames Patrick Steinhardt
2024-10-23 15:04 ` [PATCH 1/3] compat/mingw: share file handles created via `CreateFileW()` Patrick Steinhardt
2024-10-23 16:18   ` Kristoffer Haugsbakk
2024-10-23 17:25     ` Taylor Blau
2024-10-23 17:23   ` Taylor Blau
2024-10-23 17:25     ` Taylor Blau
2024-10-24  6:30     ` Patrick Steinhardt
2024-10-27 13:14     ` Johannes Sixt
2024-10-27 23:46       ` Taylor Blau
2024-10-23 15:05 ` [PATCH 2/3] compat/mingw: allow deletion of most opened files Patrick Steinhardt
2024-10-23 16:17   ` Kristoffer Haugsbakk
2024-10-23 17:30     ` Taylor Blau
2024-10-24  6:30     ` Patrick Steinhardt
2024-10-23 18:07   ` Taylor Blau
2024-10-23 15:05 ` [PATCH 3/3] compat/mingw: support POSIX semantics for atomic renames Patrick Steinhardt
2024-10-23 16:19   ` Kristoffer Haugsbakk
2024-10-24  6:30     ` Patrick Steinhardt
2024-10-24  7:18       ` Kristoffer Haugsbakk
2024-10-24  7:20         ` Patrick Steinhardt
2024-10-23 18:30   ` Taylor Blau
2024-10-23 15:36 ` [PATCH 0/3] compat/mingw: implement POSIX-style " Taylor Blau
2024-10-24 11:46 ` [PATCH v2 " Patrick Steinhardt
2024-10-24 11:46   ` [PATCH v2 1/3] compat/mingw: share file handles created via `CreateFileW()` Patrick Steinhardt
2024-10-24 11:46   ` [PATCH v2 2/3] compat/mingw: allow deletion of most opened files Patrick Steinhardt
2024-10-27 13:17     ` Johannes Sixt
2024-10-27 15:38       ` Patrick Steinhardt
2024-10-27 23:48         ` Taylor Blau
2024-10-27 23:51           ` Taylor Blau
2024-10-24 11:46   ` [PATCH v2 3/3] compat/mingw: support POSIX semantics for atomic renames Patrick Steinhardt
2024-10-27 13:23     ` Johannes Sixt
2024-10-27 15:38       ` Patrick Steinhardt
2024-10-27 16:31         ` Johannes Sixt
2024-10-27 17:27           ` Patrick Steinhardt
2024-10-27 21:36             ` Johannes Sixt
2024-10-27 23:50               ` Taylor Blau
2024-10-24 16:47   ` [PATCH v2 0/3] compat/mingw: implement POSIX-style " Taylor Blau
2024-10-27 13:27   ` Johannes Sixt
2024-10-27 15:39 ` [PATCH v3 " Patrick Steinhardt
2024-10-27 15:39   ` [PATCH v3 1/3] compat/mingw: share file handles created via `CreateFileW()` Patrick Steinhardt
2024-10-27 15:39   ` [PATCH v3 2/3] compat/mingw: allow deletion of most opened files Patrick Steinhardt
2024-10-27 15:39   ` [PATCH v3 3/3] compat/mingw: support POSIX semantics for atomic renames Patrick Steinhardt
2024-11-06  3:54   ` [PATCH v3 0/3] compat/mingw: implement POSIX-style " Junio C Hamano
2024-11-06  6:44     ` Johannes Sixt
2024-11-06 12:09       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).