Commit 1935497
committed
fix(core.utils): retry path.unlink on Windows sharing violations
CI on win-64 hit ``PermissionError: [WinError 5] Access is denied`` in
``test_concurrent_eviction_does_not_delete_replaced_file``: an evictor
trying to unlink an entry that another process briefly held open for a
read crashed the writer that triggered eviction.
Python's ``open(p, "rb")`` does not pass ``FILE_SHARE_DELETE``, so a
reader from another process briefly blocks our unlink. Mirror the
existing ``_replace_with_sharing_retry`` and ``_stat_and_read_with_sharing_retry``
helpers with ``_unlink_with_sharing_retry``: same backoff budget, same
winerror set (5/32/33 + EACCES), same non-Windows passthrough.
Apply at every entry-file unlink site:
* ``_prune_if_stat_unchanged`` -- best-effort, catches both FileNotFoundError
and the post-retry PermissionError.
* ``__init__`` schema-mismatch wipe -- same, with a comment that the
next open will retry.
* ``__delitem__`` -- retries; FileNotFoundError still maps to KeyError;
exhausted-budget PermissionError propagates so explicit deletes fail
loudly.
* ``_enforce_size_cap`` -- retries; on exhausted budget the entry is
skipped (a later eviction pass will retry) instead of crashing the
writer that triggered eviction.
Tests cover the retry-then-succeed path, the non-Windows passthrough,
and the eviction skip-on-locked path.1 parent 2bf4dad commit 1935497
2 files changed
Lines changed: 133 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
1197 | 1233 | | |
1198 | 1234 | | |
1199 | 1235 | | |
| |||
1205 | 1241 | | |
1206 | 1242 | | |
1207 | 1243 | | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1208 | 1248 | | |
1209 | 1249 | | |
1210 | 1250 | | |
| |||
1214 | 1254 | | |
1215 | 1255 | | |
1216 | 1256 | | |
1217 | | - | |
1218 | | - | |
| 1257 | + | |
| 1258 | + | |
1219 | 1259 | | |
1220 | 1260 | | |
1221 | 1261 | | |
| |||
1307 | 1347 | | |
1308 | 1348 | | |
1309 | 1349 | | |
| 1350 | + | |
| 1351 | + | |
1310 | 1352 | | |
1311 | | - | |
1312 | | - | |
| 1353 | + | |
| 1354 | + | |
1313 | 1355 | | |
1314 | 1356 | | |
1315 | 1357 | | |
| |||
1390 | 1432 | | |
1391 | 1433 | | |
1392 | 1434 | | |
1393 | | - | |
| 1435 | + | |
1394 | 1436 | | |
1395 | 1437 | | |
1396 | 1438 | | |
| |||
1514 | 1556 | | |
1515 | 1557 | | |
1516 | 1558 | | |
1517 | | - | |
1518 | | - | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
1519 | 1565 | | |
| 1566 | + | |
| 1567 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
739 | 817 | | |
740 | 818 | | |
741 | 819 | | |
| |||
0 commit comments