Repository navigation
fix(evidence): retry manifest parse when a peer replaced it during recovery - #162
Merged
Merged
Conversation
…covery Recovery inspects manifest.json before taking a run's journal lock. When a peer recovery won the lock and replaced the manifest by rename, the loser's open descriptor pointed at the unlinked inode, so the singleton-regular-file check saw nlink 0 and the run was reported as an invalid manifest even though the peer had recovered it. The parse now reopens manifest.json once when the opened inode reports nlink 0; hard links, symlinks and non-regular files are still rejected. Finalization under the lock also re-checks the read-only input condition, so a run a peer already finalized is indexed rather than rewritten. Closes #159
A peer recovery renames manifest.json twice while it holds the journal lock, once to seal it and once to publish it with the report, so a reader outside the lock can land on an unlinked inode twice and exhaust the bounded retry. Manifest inspection now reports that case as "replaced" instead of invalid, and recovery takes the journal lock and re-reads what the peer left; under the lock no cooperating rename can happen, so one retry stays enough there. Hard links, symlinks and special files are still refused as unsafe. Reading the manifest now opens and closes each descriptor exactly once, and the tests cover both peer renames landing across a reader's two opens and a peer finalizing a run between inspection and the lock.
Member
Author
8 tasks done
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.
Recovery inspects
manifest.jsonbefore taking a run's journal lock. When a peer recovery won the lock and replaced the manifest by rename, the loser's open descriptor pointed at the unlinked inode, so the singleton-regular-file check sawnlink === 0and the run was reported as skipped with reasoninvalid evidence manifestalthough the peer had recovered it.The parse now reopens
manifest.jsononce when the opened inode reportsnlink === 0. Hard links (nlink >= 2), symlinks and non-regular files are still rejected through the unchangedO_RDONLY|O_NOFOLLOW|O_NONBLOCKopen and singleton check. Finalization under the lock also re-checks the read-only input condition, so a run a peer already finalized is indexed rather than rewritten. Tests: deterministic rename between open and stat, a hard-linked manifest still skipped, and the four-process race now requires every process to report the same recovered state.Validation:
bunx vitest run packages/core(28 files, 664 tests),bun run lint,bunx tsc --noEmit,bunx complexity-gate check --changed.Closes #159