Skip to content

Avoid ftruncate during ledger rollback#7979

Draft
Copilot wants to merge 7 commits into
mainfrom
copilot/avoid-ftruncates
Draft

Avoid ftruncate during ledger rollback#7979
Copilot wants to merge 7 commits into
mainfrom
copilot/avoid-ftruncates

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Closes #7837.

Ledger rollback used ftruncate() on the hot path, which is expensive on Azure Files. Committed ledger files still need canonical sizes across nodes, so physical truncation is deferred until chunk completion.

  • Rollback path

    • Replaces immediate physical shrink with a truncation marker written at the logical end of the ledger file.
    • Recovery treats the marker as an invalid oversized entry and stops before stale tail data.
  • Completion path

    • Performs the eventual ftruncate() when completing the ledger chunk.
    • Preserves canonical completed/committed file sizes.
  • Coverage

    • Adds ledger unit coverage for deferred physical shrinking, recovery after marker writes, and eventual shrink before commit.
// Rollback now records the logical end without shrinking the file immediately.
write_truncation_marker(physical_size);

// Completion later canonicalizes the file size.
truncate_physical_file(completed_file_size);

Copilot AI and others added 5 commits June 24, 2026 21:13
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid ftruncates

2 participants