Repository navigation
Backport(v1.19): buffer: fix an enqueued unstaged file chunk being re-staged and flushed twice (#5517) - #5532
Merged
Merged
Conversation
…ed twice (#5517) **Which issue(s) this PR fixes**: Fixes #4662 **What this PR does / why we need it**: `FileChunk#enqueued!` and `FileSingleChunk#enqueued!` did nothing for an unstaged chunk, so a chunk enqueued by `Buffer#enqueue_unstaged_chunk` stayed `:unstaged` and `Buffer#write` re-staged it, leaving the same chunk object in both `@queue` and `@stage`. The second flush of that object produced `closed stream` and `ENOENT`, and the buffer size gauges leaked (see #4662 (comment)). This change marks an unstaged chunk as `:queued` and renames its files to the queued path in `enqueued!`, and makes `Buffer#write` warn instead of raise when enqueueing a chunk fails, because the chunk is already queued and a chunk left unstaged there would be purged with its committed records. A chunk whose rename failed keeps its staged file name, so `FileSingleBuffer#resume` now enqueues a second staged chunk file with the same metadata as `FileBuffer#resume` already does, and `file_rename` reopens the old file when the rename fails on Windows. **Docs Changes**: None **Release Note**: * buffer: fix an enqueued unstaged file chunk being re-staged and flushed twice, which caused `closed stream` / `ENOENT` errors and leaked buffer size gauges Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Watson1978
approved these changes
Oct 11, 2026
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.
Which issue(s) this PR fixes:
Backport #5517
Fixes #4662
What this PR does / why we need it:
FileChunk#enqueued!andFileSingleChunk#enqueued!did nothing for an unstaged chunk, so a chunk enqueued byBuffer#enqueue_unstaged_chunkstayed:unstagedandBuffer#writere-staged it, leaving the same chunk object in both@queueand@stage. The second flush of that object producedclosed streamandENOENT, and the buffer size gauges leaked (see #4662 (comment)). This change marks an unstaged chunk as:queuedand renames its files to the queued path inenqueued!, and makesBuffer#writewarn instead of raise when enqueueing a chunk fails, because the chunk is already queued and a chunk left unstaged there would be purged with its committed records. A chunk whose rename failed keeps its staged file name, soFileSingleBuffer#resumenow enqueues a second staged chunk file with the same metadata asFileBuffer#resumealready does, andfile_renamereopens the old file when the rename fails on Windows.Docs Changes:
None
Release Note:
closed stream/ENOENTerrors and leaked buffer size gauges