Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adds bounded retry/backoff around LocalFileStreamProvider.Replace to handle transient File.Replace failures on Windows - #174

Merged
koculu merged 1 commit into
mainfrom
file-replace-retry-backoff
Aug 4, 2026
Merged

Adds bounded retry/backoff around LocalFileStreamProvider.Replace to handle transient File.Replace failures on Windows#174
koculu merged 1 commit into
mainfrom
file-replace-retry-backoff

Conversation

@koculu

@koculu koculu commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Adds bounded retry/backoff around LocalFileStreamProvider.Replace to handle transient File.Replace failures on Windows, such as watcher-related interference from tools like editors or file indexers.

The implementation preserves ZoneTree’s existing atomic replacement behavior by continuing to use File.Replace; it only retries transient IOExceptions before surfacing the original failure.

Changes

  • Retry File.Replace on retryable IOExceptions with short bounded backoff delays: 10ms, 25ms, 50ms, 100ms, 200ms.
  • Avoid retries for structural path/file errors such as:
    • FileNotFoundException
    • DirectoryNotFoundException
    • DriveNotFoundException
    • PathTooLongException
  • Add deterministic unit tests for:
    • eventual success after transient failures
    • rethrow after retry exhaustion
    • no retry for missing source file

Motivation

On Windows, File.Replace may fail transiently with errors like “Unable to remove the file to be replaced” when another process has a FileSystemWatcher active on the directory. Retrying briefly handles that interference without replacing the atomic operation with a less durable delete/move fallback.

…o handle transient `File.Replace` failures
@koculu
koculu merged commit 910f9db into main Aug 4, 2026
1 check passed
@koculu
koculu deleted the file-replace-retry-backoff branch August 4, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant