You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tail: do not panic when the file is truncated while scanning backwards - #16042
ReverseChunks measures the file size once in new() and then calls read_exact(...).unwrap() for every block. If the file is truncated (for
example by log rotation or another writer) after the size was measured, the
backwards seek still succeeds but the read returns UnexpectedEof, so tail -n N FILE panics with exit status 101 (or SIGABRT in release builds).
Treat a failed read in the backwards scan as the start of the file instead of
panicking, so a concurrently truncated file no longer aborts tail. GNU tail
also exits successfully in this situation.
A unit test covers the truncation-after-measurement case.
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
No successful run was found on main (19f6602) during the generation of this report, so 8e267ce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
thanks for looking into this!
real read errors still end in a panic, so tail still aborts. please return them as errors instead, see the inline comments.
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
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.
ReverseChunksmeasures the file size once innew()and then callsread_exact(...).unwrap()for every block. If the file is truncated (forexample by log rotation or another writer) after the size was measured, the
backwards seek still succeeds but the read returns
UnexpectedEof, sotail -n N FILEpanics with exit status 101 (or SIGABRT in release builds).Treat a failed read in the backwards scan as the start of the file instead of
panicking, so a concurrently truncated file no longer aborts
tail. GNU tailalso exits successfully in this situation.
A unit test covers the truncation-after-measurement case.
Closes #15755