Repository navigation
Register FULL hydration so reads and writes wait for the whole file - #13
Merged
Merged
Conversation
…oaded The drive registered PARTIAL hydration, which Microsoft documents as not supported and which Windows runs as PROGRESSIVE (the default for programs; the higher of the two applies). PROGRESSIVE lets a read through as soon as its bytes arrive and finishes the download a moment later. A write in between could lose the downloaded bytes: on CI, the read and append in UpdatePlaceholderContractTest read back as 11 zeros followed by the appended text (runs 45843777423 and 45879816676). It showed only on CI. On a PC, Defender's real-time protection downloads a file as soon as a program opens it for reading, so the test's own read never drove the download; CI runners turn real-time monitoring off. Reproduced locally by reading through a handle opened before the file was freed up: 9 of 9600 rounds read back as zeros with PARTIAL, none with FULL. FULL is what Nextcloud (cfapiwrapper.cpp) and OneDrive register: the platform completes a read only once the whole file is local. It also keeps what a program appends to an online-only file, which PARTIAL lost for a 70 KB file. ARead_ReturnsOnlyOnceTheWholeFileIsHere pins it and fails every time with PARTIAL. The E2E mount check now expects the mark to be gone right after the read instead of waiting for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With FULL hydration, a program's write to a file that is not fully on disk makes Windows download all of it first, so such a file holds nothing local. The test that wrote to one without downloading it (#11) can no longer do so. The hold stays: a program that has the file open can have a write waiting for that download, which could land between the check and the replace. That test now holds the file open without writing to it. A new one, AWrite_ToAFileNotFullyOnDisk_DownloadsAllOfItFirst, pins that a write downloads the whole file first; it fails with PARTIAL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 3 tasks
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.
Replaces #12, rebuilt on main now that #11 is merged. It registers FULL hydration and updates #11's test, comment and docs to match.
Why FULL
The drive registered
PARTIALhydration. Microsoft's reference saysPARTIAL"is not currently supported" and behaves likePROGRESSIVE, which programs get by default anyway (sync engine docs). UnderPROGRESSIVE, Windows completes a read as soon as its bytes arrive and finishes the download a moment later. A write in that gap can lose the downloaded bytes. That is the intermittent CI failure inUpdatePlaceholderContractTest, where a file came back as"\0\0\0\0\0\0\0\0\0\0\0-edited"(runs 45843777423 attempt 1 and 45879816676). Any program that reads a file and writes to it at once could hit it, and the engine would then upload the zeros as an edit.It only failed on CI. On a PC, Defender's real-time protection downloads the whole file as soon as a program opens it, so the test's own read never starts the download. GitHub's runners turn real-time monitoring off (Configure-WindowsDefender.ps1).
Local reproduction, with temporary experiments not included here: the reader was opened while the file was downloaded, the file was freed up through a
WRITE_DAC-only handle, and then the reader read it.PARTIAL(before)FULL(after)-edited(8 workers × 400 rounds × 3 runs)Nextcloud registers
CF_HYDRATION_POLICY_FULL(src/libsync/vfs/cfapi/cfapiwrapper.cpp), and OneDrive's sync roots on the test PC areFull.What it means for #11's hold
Under FULL, every local change tried on an online-only file downloads it first: append, write at the start, truncate, extend, truncate-on-open, and memory-mapped writes. An overwrite makes it a plain file. So a file that is not fully on disk holds nothing local. #11's hold, which stops a server change from replacing such a file while another program has it open, is kept. That program can have a write waiting for the download, which could land between the engine's check and its replace.
Changes
SyncRootRegistrarregistersFULLin both the shell path and theCfRegisterSyncRootfallback. Existing drives pick it up when the service re-registers at startup.ARead_ReturnsOnlyOnceTheWholeFileIsHerefails 8/8 underPARTIALand passes 8/8 underFULL.AWrite_ToAFileNotFullyOnDisk_DownloadsAllOfItFirstfails underPARTIALfor an online-only file. UnderPARTIAL, the bytes appended to a 70 KB online-only file were also lost; that is fixed too.UpdateFromRemote_UnchangedFrom_RefusesAFileNotFullyOnDiskWhileOpenInAnotherProgram(Hold a file not fully on disk before replacing it; clear leftover test drives #11) now holds the file open without writing. With FULL, its write downloaded the file.CloudPlaceholderService.UpdateFromRemoteand the architecture doc say why the hold stays.Test plan
dotnet test .\OpenCfDrive.slnx --settings coverage.runsettings: 297 passed locallyPARTIAL🤖 Generated with Claude Code