Add explicit save completion for sync volumes - #30
Open
raphaeldelio wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An application can finish writing to an AFS sync mount while some files are still waiting to reach Redis. If its microVM stops then, the next session can restore an incomplete directory. AFS has no native command that confirms the entire included local tree has been saved. An empty event queue cannot establish this because uploads may still be running and watcher events may have been missed.
Solution
Add
afs vol save [--timeout 2m] [--json] <volume|directory>for a mounted sync volume.The daemon pauses background sync, lets active uploads finish, then saves and verifies the included local tree against Redis. It checks actual file bytes, paths, types, permissions and symlink targets, and rejects local changes during the operation. Success returns a receipt with entry and file counts, byte count, a tree SHA256 and completion time. Normal sync resumes with fresh workers.
Save reuses the local manifest verified after shutdown. Existing file operations and save share their request file transport; save retains its deadline, mount identity and receipt checks. Requests are polled independently of watcher events.
Callers must stop local and remote writers before saving. Conflicts, failed transfers, changing files and timeouts return errors. Failure can leave partial writes. Success confirms Redis visibility; it does not guarantee Redis disk persistence, an atomic snapshot under concurrent writes, or create a checkpoint.
The branch starts directly from main and requires neither #28 nor #29.
Validation
go vet, Linux ARM64 save/control tests and all 26 POC harness tests passed. Regressions cover missed events, large files, conflicts, failures, deadlines, worker shutdown, legacy file operations and local edits after manifest capture.--timeout 10m: 169.3 seconds applying changes, 93.8 seconds reading back Redis, and 0.94 seconds across all four local scans. The default two minute timeout is insufficient for this workload. Profiling code is not included in the PR; these timings do not establish a speedup over the earlier run on a smaller Redis host.