Commit 7f2247d
authored
🐛 fix(win): restore best-effort lock file cleanup on release (#511)
Version 3.25.0 introduced a regression on Windows where lock files were
no longer cleaned up after release, leaving orphaned `.lock` files on
disk. 🗑️ Users upgrading from 3.18.0 reported that their single-threaded
applications now leave persistent lock files, breaking the expected
behavior and diverging from how Unix platforms work (where lock files
are cleaned up).
The regression came from PR #484, which removed the `unlink()` call to
fix threading race conditions. While that fix correctly addressed
multi-threaded scenarios where Windows cannot delete files with open
handles, it sacrificed cleanup for the common single-threaded use case
where deletion would succeed.
This fix restores opportunistic cleanup by attempting to unlink the lock
file after closing it, with errors suppressed via `suppress(OSError)`. ✨
In single-threaded scenarios, the file deletes successfully and users
get the expected behavior. In multi-threaded scenarios where other
threads hold handles, the deletion fails silently and the lock file
persists, preserving the thread-safety guarantees from PR #484.
The test suite is updated to remove the Windows skip condition from
`test_lock_file_removed_after_release`, as Windows now supports cleanup
in typical usage patterns.
Closes #5091 parent 5ae1c4e commit 7f2247d
4 files changed
Lines changed: 28 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
148 | 156 | | |
149 | 157 | | |
150 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 906 | + | |
915 | 907 | | |
916 | 908 | | |
917 | 909 | | |
| |||
0 commit comments