Close and reopen active recovery ledger chunks to preserve SMB write-caching - #8071
Closed
andpiccione wants to merge 5 commits into
Closed
Close and reopen active recovery ledger chunks to preserve SMB write-caching#8071andpiccione wants to merge 5 commits into
andpiccione wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts host-ledger recovery finalization so that writable (uncommitted) .recovery ledger chunks are closed before being renamed to their final names and then reopened, avoiding SMB/CIFS client lease/write-caching degradation after rename on some Linux kernels/filesystems. It also adds regression tests around recovery completion and documents the fix in the changelog.
Changes:
- Update
LedgerFile::open()to close → rename → reopen uncommitted recovery chunks when completing recovery. - Add host-ledger unit tests asserting recovery completion preserves open-FD counts and that post-recovery writes/truncation still work.
- Add a changelog entry describing the Azure Files/SMB latency regression and the mitigation.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md.github/instructions/changelog.instructions.md
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/host/ledger.h |
Implements close/rename/reopen flow for uncommitted recovery chunks during complete_recovery(). |
src/host/test/ledger.cpp |
Adds recovery-focused tests validating FD stability and continued write/truncate behavior after recovery completion. |
CHANGELOG.md |
Documents the SMB/Azure Files recovery-ledger write-latency fix. |
andpiccione
force-pushed
the
fix/rename-smb-lease-break-fix
branch
from
July 16, 2026 03:55
aee831c to
d6765a0
Compare
andpiccione
marked this pull request as ready for review
July 16, 2026 05:07
Member
|
Replaced by #8072 |
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.
When a node starts from a snapshot - a backup joining a network, or a node recovering - the host ledger enters recovery mode (
init_as_backup()->ledger->init(idx, recovery_start_idx)). Entries replicated/appended after the snapshot point are written to temporaryledger_X.recoverychunks. Once the service is observed OPEN,complete_recovery()->LedgerFile::open()renames eachledger_X.recoveryto its finalledger_Xname while the active chunk's write handle is still open.On Azure Files (SMB) with a CIFS client lacking the upstream fix
2c7d399e551c(in Linux 6.6.32, not backported to 6.1.y, so current C-VN2 at 6.1.x is affected), renaming a file with an open write handle breaks that handle's write-caching lease. The handle never regains write caching, so every later ledger write becomes a synchronous server round-trip (~2000x slower), which starves the ledger writer and can stall a joining or recovering node.The proposed simple fix is to close the handle before the rename and reopen the renamed file so it gets a fresh lease, for chunks that can still be written:
!committed):fclose->files::rename->fopen("r+b"). These are still appended to, or can be truncated by a rollback and rewritten.The predicate is
committed(notcompleted) because a completed chunk can be un-completed by a post-recovery truncate and then written again. Failures are fail-stop (fclose/fopenchecked,filenulled before throw, throwing rename), and the.recoverycrash-marker semantics are unchanged. The change is confined to the single finalize-rename site (LedgerFile::open()), so it covers every path that produces.recoverychunks (join and recovery alike). No format, API, or platform-detection change.I verified these changes on C-VN2, and the results are as expected. Slow writes are no longer appearing when starting a fresh network because the write degradation is gone.