-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(buffers): recompute disk_v2 buffer size on restart to prevent underflow #25767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
graphcareful
wants to merge
1
commit into
vectordotdev:master
Choose a base branch
from
graphcareful:fix/disk-v2-recompute-buffer-size-on-restart
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fixed a `disk_v2` buffer accounting bug where the unread-bytes counter (`total_buffer_size`) could underflow on restart. Previously the buffer seeded the counter from the sum of on-disk data file sizes and then had the reader decrement it record-by-record while seeking to its persisted read position. Those two inputs were captured at different moments — the data files on disk versus the read position in the ledger, which are flushed on independent schedules — so a crash between their flushes could make the decrements exceed the seeded total. Because the counter is unsigned, the subtraction wrapped to a near-maximum value, making the buffer appear permanently full and wedging the writer (no further writes accepted, and recovery could stall). The reader now recomputes the unread total authoritatively at the end of its startup seek, from a single consistent snapshot — the total size of the data files still on disk minus the bytes it consumed reaching the resume position — so the counter can no longer underflow across a restart. | ||
|
|
||
| authors: graphcareful |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When startup hits a bad read after consuming a valid prefix of the current file,
next()callsroll_to_next_data_file(), which resetsself.bytes_readbeforeseek_to_next_record()reaches this recompute. The skipped file still exists and is included bytotal_data_file_size(), so this subtraction treats the already-consumed/acknowledged prefix as unread; on buffers nearmax_size, the reopened writer can block on the inflated size while the reader is waiting for the writer to create the next file.Useful? React with 👍 / 👎.