Repository navigation
fix(file source): avoid remove_after deleting files with buffered partial lines or oversized discards - #27317
Draft
lukesteensen wants to merge 1 commit into
Draft
lukesteensen wants to merge 1 commit into
lukesteensen wants to merge 1 commit into
Conversation
…tial lines or oversized discards
This branch has not been deployed
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.
Summary
Fixes two related bugs where
remove_after_secsdeletes an active file prematurely:bytes_read == 0andwatcher.last_read_success().elapsed() >= remove_after,FileServerunlinked the file and marked the watcher dead without checking whetherFileWatcher::bufstill held an incomplete partial line awaiting its delimiter — silently discarding the buffered bytes.FileLineTooLongdropped: WhenFileWatcher::read_linediscarded a line exceedingmax_line_bytesand then hit EOF (raw_line: None),FileServer'swhile let Ok(RawLineResult { raw_line: Some(..), .. })loop exited without emittingFileLineTooLong, did not count the discard as read progress, and allowedremove_afterto immediately delete the file.This PR adds
FileWatcher::has_buffered_data(), updateslast_read_successwhen oversized lines are discarded, emitsFileLineTooLongeven whenraw_lineisNone, and skipsremove_afterdeletion while partial data is buffered or an oversized line was just discarded.Vector configuration
N/A
How did you test this PR?
lib/file-source/src/file_server.rs:remove_after_zero_does_not_delete_file_with_buffered_partial_lineremove_after_does_not_delete_file_on_oversized_line_discardcargo clippy -p file-source --all-targets -- -D warningscargo test -p file-source --lib -- remove_after_Does this PR include user facing changes?
remove_after_secsand emittingFileLineTooLongwhen no normal line follows (changelog fragment to be added before marking ready for review).no-changeloglabel to this PR.