fix(server): prevent partial parallel loads from becoming valid cache#1281
Merged
szbr9486 merged 2 commits intoJul 25, 2026
Merged
Conversation
szbr9486
reviewed
Jul 24, 2026
szbr9486
reviewed
Jul 24, 2026
szbr9486
approved these changes
Jul 25, 2026
szbr9486
approved these changes
Jul 25, 2026
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.
Summary
Prevent a cancelled or incomplete parallel UFS-to-Curvine load from stamping
ufs_mtimeon a pre-resized target and becoming a false cache hit.Issue Describe / Design
Root cause
run_parallelpre-creates the target and callsresize(src_len)before copying. This is required for disjoint multi-writer ranges, but it also means the target metadata reports the full source length before every range contains data.Each join-loop iteration checks
task.is_cancel()before awaiting a stream handle. A race remains for the final handle:false.Ok(0)as a soft exit.Ok(0)and ends; there is no next iteration to recheck cancellation.ufs_mtimeon the target even though the final range is incomplete.FileStatus::cv_validcan then accept the target because its pre-resized length and stamped mtime match the UFS source.The result is a false cache hit: later load or read paths may skip reloading an incomplete file.
Trigger conditions
The race requires all of the following:
effective_streams > 1);Cancellation can come from a user cancel request, a duplicate task superseding the current runner, or master cleanup after a partial dispatch failure.
Fix approach
task.is_cancel()immediately after all stream handles join and before stamping cache validity. Cancellation remains a softOk(())exit, preserving existing task-state semantics.written == src_lenfor the non-cancelled path. Any mismatch is reported as a data-integrity error and refuses to stampufs_mtime.ufs_mtimeonly after both integrity gates pass.Changes
curvine-server/src/worker/task/load_task_runner.rscurvine-server/tests/load_task_runner_fault_test.rscurvine-tests/regression/daily_regression_test.shcurvine-server/fault-injectionfor Nextest discovery and specific server testsTest verified
cargo fmt --all --checkcargo clippy -p curvine-server --all-targets --features fault-injection -- -D warnings --allow clippy::uninlined-format-argscargo test -p curvine-server --lib worker::task::load_task_runnercargo nextest run --workspace --profile ci-no-ufs --features curvine-server/fault-injection -E 'test(canceled_final_parallel_stream_does_not_mark_cache_valid)'daily_regression_test.sh ... curvine-server load_task_runner_fault_test canceled_final_parallel_stream_does_not_mark_cache_validbash -n curvine-tests/regression/daily_regression_test.shmake formatcurvine-fuse/src/fs/state/node_state.rsDependencies