Repository navigation
Conversation
Engine::update_chunk inserted the in-memory WritingHolder before putting the writing-chunk journal. When the journal put failed (RocksDB error), the holder stayed in writing_list with abort=false, so the chunk was reported as uncommitted and every later update on it failed with "chunk is in writing" until restart. Persist the journal first and only publish the holder after it succeeds. This also keeps the ordering introduced for remove intent: the journal always reflects is_remove before the holder becomes visible. Tests: cargo test -p chunk_engine --lib. Add test_engine_update_failure_does_not_leave_stuck_writing_holder, which injects a journal persist failure and asserts the writing list stays empty and the same chunk can be written again. The test fails when the holder is published before the journal.
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
Engine::update_chunkinserted the in-memoryWritingHolderbefore persisting the writing-chunk journal. If the RocksDB put failed, the holder stayed inwriting_listwithabort = false: the chunk looked uncommitted,query_all_chunksreported a phantom pending version, and every later update returnedInvalidArg("chunk ... is in writing")until the process restarted.Root Cause
The update path had no rollback for the holder registration:
persist_writing_chunkwas called afterwriting_list.entry(...).insert_entry(...)and its error propagated while the in-memory state stayed published.Changes
src/storage/chunk_engine/src/core/engine.rsis_removebefore the holder becomes visible.test_engine_update_failure_does_not_leave_stuck_writing_holder, using a thread-local test-only fault injection that makes the next journal put fail. The test asserts the writing list andquery_uncommitted_chunksstay empty and that the same chunk can be written immediately afterwards.Verification
The regression test fails when the holder is published before the journal (verified by temporarily restoring the old order). The fault injection is thread-local so parallel tests cannot observe each other's injected failure.
Compatibility
No on-disk format change. Only the failure path changes: a failed journal put now returns the RocksDB error without leaving stale in-memory state.
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.