Repository navigation
indexers: fix flatfile recovery and durability - #434
Merged
kcalvinalvin merged 2 commits intoSep 7, 2026
Merged
kcalvinalvin merged 2 commits into
kcalvinalvin merged 2 commits into
Conversation
kcalvinalvin
force-pushed
the
fix/flatfile-recovery-and-durability
branch
from
September 7, 2026 05:51
f31f003 to
9919824
Compare
Restore the append cursor from the last readable record, including resetting it when recovery removes every record. Publish an offset only after its data write succeeds, and update the in-memory offsets only after publication. Validate overwrite framing, payload bounds, and impossible zero offsets before writing. This prevents a corrupt TTL lookup from redirecting updates into another record or its header. Cover recovery followed by append, an empty recovered index, cross-record writes, zero-offset aliases, and failed data writes. These guards address concrete failure modes; they do not establish the cause of historical corruption or provide power-loss atomicity.
Flush record data before its offset table, then propagate sync failures before invoking FlushMainDB during a connecting index flush. Include only initialized states so pruned indexes do not dereference archive-only files. Test both archive and pruned modes and verify that a flat-file sync failure prevents the main database callback from running. This improves the existing explicit flush boundary. It does not cover independent main database flushes, transactional TTL rollback, disconnects, or power loss between writes to different files. Those require a broader commit/recovery protocol and crash-injection coverage.
kcalvinalvin
force-pushed
the
fix/flatfile-recovery-and-durability
branch
from
September 7, 2026 07:11
9919824 to
da90eef
Compare
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.
• This came out of recovering a corrupted flat proof index on my bridge node. There were zero offsets at one height, and TTL writes through those offsets ended up overwriting historical record headers.
This fixes a few things that made that possible:
Added regression tests for these cases.
go test ./blockchain/... -count=1passes.This isn't a complete crash-consistency fix yet. The flat files and main DB still aren't committed atomically, and independent DB flushes and disconnects need more work.