fix: restore the tail data file when a reopen's local write fails - #491
fix: restore the tail data file when a reopen's local write fails#491thweetkomputer wants to merge 1 commit into
Conversation
A cloud reopen syncs the tail data file via DownloadFile(download_to_exist=true), which renames the existing file aside to .tmp before rewriting it. If the local WriteFile then fails (e.g. cache-disk ENOSPC), the file was left stranded as .tmp: its committed pages became briefly unreadable (ResourceMissing before an auto-reopen heals it) and its used_local_space_ charge was orphaned, inflating cache accounting until restart. Track whether the existing file was moved aside and, on write failure, rename it back before returning the error. This preserves the committed prefix -- WriteFile only touches bytes at/after offset, i.e. the not-yet-installed tail no live snapshot maps, so the reader-visible prefix is intact. Restoring (rather than discarding) is required because the file holds committed pages current readers need. The final tmp->filename rename is trusted (a directory op that only fails on hardware). Regression: a cloud [reopen] test arms a WriteFile fail point during a reopen's tail sync and asserts no .tmp is left stranded in the partition directory (one is stranded without the fix).
|
Warning Review limit reached
Next review available in: 34 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
A cloud reopen syncs the tail data file via
DownloadFile(download_to_exist=true), which renames the existing file aside to.tmpbefore rewriting it in place. If the localWriteFilethen fails (e.g. cache-disk ENOSPC), there was no rename-back — the file was left stranded as.tmp:ResourceMissing, which an auto-reopen then heals), andused_local_space_charge was orphaned while the eventual re-download charged again, inflating cache accounting until restart.Fix
Track whether the existing file was actually moved aside (
moved_existing) and, onWriteFilefailure, rename it back before returning the error.WriteFileonly writes bytes at/afteroffset— the not-yet-installed tail that no live snapshot maps — so the reader-visible prefix is byte-for-byte intact.tmp→filenamerename is trusted (a directory op that only fails on hardware).Test
A cloud
[reopen]test arms aWriteFilefail point during a reopen's tail sync and asserts no.tmpis left stranded in the partition directory (exactly one is stranded without the fix). Reads alone don't surface the bug — the committed pages stay in the buffer-pool cache and a cold-read fault self-heals via auto-reopen — so the regression is verified at the filesystem level. Full cloud suite passes (218 assertions).