Open
Conversation
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Avoid ftruncates in rollback path
Avoid ftruncate during ledger rollback
Jun 24, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #7837 by removing ftruncate() from the ledger rollback hot path (notably expensive on Azure Files) while preserving the invariant that completed/committed ledger chunk files are byte-identical across nodes. It introduces a “logical truncation” marker to prevent recovery from replaying stale tail bytes, and defers the eventual physical truncation to chunk completion time.
Changes:
- Add a truncation-marker mechanism in
asynchost::LedgerFileto represent a logical rollback without immediately shrinking the file. - Teach incomplete-ledger recovery to treat the marker as an intentional logical EOF and track deferred physical truncation state.
- Add a host-ledger unit test covering deferred shrink behavior, crash/restart recovery behavior, and byte-for-byte equivalence with a canonical committed ledger.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/host/ledger.h | Implements deferred truncation via a truncation marker during rollback/rewrite, recognizes marker during recovery, and performs physical truncation during completion. |
| src/host/test/ledger.cpp | Adds a regression test validating deferred physical shrink, crash recovery behavior, and equivalence of committed outputs versus a canonical baseline. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Closes #7837.
Ledger rollback used
ftruncate()on the hot path, which is expensive on Azure Files. Committed ledger files still need canonical sizes and contents across nodes, so physical truncation is deferred until chunk completion.ftruncate()before publishing the positions table offset.