Repository navigation
content: handle sharing violations on Windows - #13329
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces Windows CI flakes in the local content store by adding Windows-specific retry behavior around filesystem operations that can fail transiently due to sharing violations.
Changes:
- Add Windows implementations of
removePath(retryingos.RemoveAll) andreadFileWithRetry(retryingos.ReadFile) with a small backoff. - Add non-Windows passthrough implementations of the same helpers.
- Switch
store.AbortandreadFileTimestampto use the new helpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
plugins/content/local/store_windows.go |
Adds retrying wrappers for remove/read to mitigate transient Windows sharing violations. |
plugins/content/local/store_other.go |
Adds non-Windows passthrough implementations to keep call sites platform-agnostic. |
plugins/content/local/store.go |
Routes Abort cleanup and timestamp reads through the new helper functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
91d00a3 to
0bda8f9
Compare
There was a problem hiding this comment.
Pull request overview
Adds Windows-specific retry handling in the local content store to avoid transient sharing-violation failures when aborting ingests and reading timestamp state files.
Changes:
- Introduces platform-specific helpers
removePathandreadFileWithRetry(Windows: retry with backoff; others: passthrough). - Updates
store.Abortto useremovePathinstead ofos.RemoveAll. - Updates
readFileTimestampto usereadFileWithRetryinstead ofos.ReadFile.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugins/content/local/store_windows.go | Adds Windows retry/backoff wrappers for RemoveAll and ReadFile to mitigate transient sharing violations. |
| plugins/content/local/store_other.go | Adds non-Windows implementations of the new helper functions (direct passthrough). |
| plugins/content/local/store.go | Switches ingest cleanup and timestamp reads to use the new helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0bda8f9 to
0a996a5
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses flaky Windows CI failures in the local content store by adding Windows-specific retries for file operations that can transiently fail due to sharing/lock violations.
Changes:
- Add Windows retry helpers for
RemoveAllandReadFileto tolerate transient sharing violations. - Route ingest cleanup (
Abort) through the retrying remove helper. - Route timestamp reads (
readFileTimestamp) through the retrying read helper, preventing status/read flakes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
plugins/content/local/store_windows.go |
Adds retry logic for Windows sharing/lock-related failures in delete/read file operations. |
plugins/content/local/store_other.go |
Provides non-Windows passthrough implementations for the new helper functions. |
plugins/content/local/store.go |
Switches Abort cleanup and timestamp reads to use the new platform-specific helper wrappers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a996a5 to
f1fa777
Compare
f1fa777 to
6f92e34
Compare
6f92e34 to
1b5a94b
Compare
1b5a94b to
3140c26
Compare
On Windows, os.RemoveAll and os.ReadFile can fail with a sharing violation when a file handle has not been fully released by the OS. Unlike Unix, Windows does not allow deleting or reading a file while any handle is open, and handles may be held briefly after Close returns. This causes a race between the gRPC server-side writer Close (which writes updatedat.tmp) and both Abort (which calls RemoveAll on the ingest directory) and status (which reads the updatedat file), surfacing as a flaky TestContentClient/CommitErrorState on Windows CI. Add platform-specific removePath and readFileWithRetry helpers that retry with incremental backoff on Windows. On non-Windows platforms they pass through to os.RemoveAll and os.ReadFile directly. This follows the same pattern as ensureRemoveAll in the CRI server helpers, which retries on EBUSY for mount races on Linux. Signed-off-by: ayush-panta <[email protected]>
3140c26 to
a26143a
Compare
Problem
Issue #11044 highlights that
TestContentClient/CommitErrorStateflakes on Windows CI with sharing violations during cleanup:Root cause
I believe the root cause is a race between the gRPC server-side
defer wr.Close()(which writesupdatedat.tmpviawriteToCompletion) and the client-side cleanup callingAbort(which runsos.RemoveAllon the ingest directory). On Unix this doesn't matter since you can unlink files with open handles. On Windows, the OS can hold handles briefly afterClose()returns, so deletes and reads hit a sharing violation.While investigating, I found the same race also affects
readFileTimestampinstatus(), where theupdatedatfile can't be read while the handle is still held. This wasn't called out in the issue, but I ran into it while testing, so I fixed it as well.Fix
Adds
removePathandreadFileWithRetryas platform-specific helpers inplugins/content/local/. On Windows they retry with linear backoff (5 attempts, 100-500ms). On other platforms they pass through directly. Same pattern asensureRemoveAllininternal/cri/server/helpers_linux.go, which retries onEBUSYfor mount races.Test results
I ran
TestContentClient/CommitErrorState500 times on a Windows Server 2022 EC2 instance (t3.large). The race reproduces naturally but infrequently (~11% with mainline containerd v2.3 on this instance type, could vary based on instance) so I used a large number of runs to get a clear signal.The "before" run uses mainline at
2976f38cc. The "after" commit hash (d0911796a) differs from the final PR commit because I amended after testing for a few edits.The three failure types are all the same underlying race hitting different operations:
abort-unlinkat:Abortcallsos.RemoveAll, fails to delete a file in the ingest directory (the original error)dir-not-empty:Abortcallsos.RemoveAll, can't remove the directory because a held file blocks child deletionread-updatedat:status()callsreadFileTimestamp, can't openupdatedatwhile the handle is still heldFixes #11044