Repository navigation
Refuse to open a store whose capsule journal is missing - #206
Merged
Merged
Conversation
A used space.db without its space.journal used to rebuild the index from a new, empty journal, leave every segment unreferenced, and let the next reclaim delete them. The registry now refuses to open a space.db that has been used without its journal, and a new journal won't pair with a data log or storage root that already holds segments. Nothing in the store changes either way. Fixes #194
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.
Fixes #194
CapsuleRegistry::openrefuses to open aspace.dbthat has a journal position whenspace.journalis missing. It checks beforeJournal::open, so no new journal is created and nothing in the store changes. The error names both files and says to restore the journal.bind_storetakes whether the data log or storage root holds segments, and refuses to let a journal with no records adopt a store that does. This covers the case wherespace.dbis gone too, from a backup that kept onlyspace.nvramor the storage root. For the data log, it checks whether there are any segments. For a storage root, it checks for any segment file, which is the same scan as the id floor. A new store with an empty data log still pairs as before.list,gcandcompactat the first, andcreateandserve-s3at whichever applies. So neither a manual compaction nor the startup reclaim can run. I leftopen_registry(Open::Existing)as it was, accepting either file: with onlyspace.dbpresent, the registry's own error is clearer than "no SPACE store".a_lost_index_never_reuses_a_segment_idloses onlyspace.db, after a deleted capsule leaves its segment file behind, which still checks the id floor. The legacy-names test forces its rebuild with another store's journal.space.nvrammakes a new log with another store id, which a journal with records refuses as "different stores". So a missing journal and a missing data log follow the same rule, as your comment asked with [fold] One generation swap for data-log and journal compaction #191 in mind.Tests: a journal test (missing journal, then missing
space.dbtoo, withspace.nvrambyte-for-byte unchanged), a storage-root test (the segment file unchanged), and a CLI test wherelist,compact,gcandserve-s3all exit with the error, no journal is created, andspace.nvramis unchanged. Then withspace.dbgone too,serve-s3andcreaterefuse. Six mutants each fail a test: either guard removed (caught at the registry and CLI level), and the data log or storage root reporting no segments. By hand, the issue's repro (a 6 MB capsule,rm space.journal,serve-s3) now exits 1 with the message, andspace.nvramstays 6000376 bytes.Docs: CHANGELOG (Fixed), on-disk-format §3, and the failure modes table in capsule.md.