Bug 10196 - tail -F loses information during log rotation
Summary: tail -F loses information during log rotation
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.23.x
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-09 14:37 UTC by Jakub Piotr Cłapa
Modified: 2019-08-29 11:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Piotr Cłapa 2017-08-09 14:37:51 UTC
Hi,

I am using svlogd for logging and tail -F current to follow on them. I noticed that sometimes I would miss some lines that were added to the files immediately before they were renamed.

I looked into the code and noticed that (when FOLLOW_RETRY is true) after sleeping tail immediately checks if the file was replaced (the inode changed) before it tries to read and print the remaining bytes. As far as I understand it this means that if the old file was appended to and the renamed it would miss this information.

Have anyone noticed it before? I probably should write a test case for this and think about a patch but I would like to hear a second opinion on this first.
Comment 1 Jan Hudec 2019-08-29 11:37:04 UTC
Hi,

Yes, this is a problem. It basically renders the FOLLOW_RETRY option useless, and subtly useless at that, because following rotated logs is the main purpose of the option.

The file shall be read to the end between checking the inode equality and reopening it.