Repository navigation
fix(chunk_engine): reject syncing writes that do not start at offset 0 - #467
Merged
SF-Zhou merged 1 commit intoNov 27, 2026
Conversation
A syncing write replaces the whole chunk and carries a checksum over the full payload. copy_on_write's skip-read path stores that checksum directly, so a syncing write with offset > 0 would persist metadata whose checksum does not cover the untouched prefix (and whose prefix was never written by the request). Reject the combination with InvalidArg. The forwarding path rewrites syncing payloads to offset 0 and StorageOperator already refuses syncing truncate/extend, so this is a defensive guard. Tests: cargo test -p chunk_engine --lib. Add test_engine_rejects_syncing_write_with_nonzero_offset; offset-0 syncing writes still succeed.
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
Reject syncing updates that do not start at offset 0 (
is_syncing && offset != 0).Root Cause
A syncing write replaces the whole chunk and carries a checksum over the full payload.
copy_on_write's skip-read path stores that caller-provided checksum directly as the new chunk checksum without reading or covering the bytes beforeoffset. If such a request reached the engine withoffset > 0, the persisted metadata would describe a checksum that does not match the actual slot content.The forwarding path normally rewrites syncing payloads to
offset = 0, andStorageOperatoralready rejects syncing truncate/extend requests, so this is a defensive guard rather than a known remote-triggerable bug.Changes
src/storage/chunk_engine/src/core/engine.rsis_syncing && offset != 0at the top ofEngine::update_chunkwithError::InvalidArg.test_engine_rejects_syncing_write_with_nonzero_offset, which also checks that a syncing write at offset 0 still succeeds.Verification
The new test fails when the guard is removed.
Compatibility
Request-validation only; normal syncing writes use offset 0 and are unaffected. No on-disk format change.
AI-assisted development disclosure: AI coding tools assisted with root-cause analysis, patch drafting, and regression test authoring; all changes and tests were reviewed and verified locally.