Skip to content

fix(chunk_engine): reject syncing writes that do not start at offset 0 - #467

Merged
SF-Zhou merged 1 commit into
deepseek-ai:mainfrom
SF-Zhou:fix/chunk-engine-reject-syncing-nonzero-offset
Nov 27, 2026
Merged

SF-Zhou merged 1 commit into
deepseek-ai:mainfrom
SF-Zhou:fix/chunk-engine-reject-syncing-nonzero-offset

Conversation

@SF-Zhou

@SF-Zhou SF-Zhou commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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 before offset. If such a request reached the engine with offset > 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, and StorageOperator already 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.rs
    • Reject is_syncing && offset != 0 at the top of Engine::update_chunk with Error::InvalidArg.
    • Add test_engine_rejects_syncing_write_with_nonzero_offset, which also checks that a syncing write at offset 0 still succeeds.

Verification

cargo test -p chunk_engine --lib
# test result: ok. 55 passed; 0 failed; 0 ignored

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.

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.
@SF-Zhou
SF-Zhou merged commit 0e876af into deepseek-ai:main Nov 27, 2026
1 check passed
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