[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch #6612] tail -F should attempt to read from old file until EOF is

From: Jos Backus
Subject: [patch #6612] tail -F should attempt to read from old file until EOF is encountered
Date: Sat, 16 Aug 2008 07:53:10 +0000
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv: Gecko/2008071720 Firefox/3.0.1


                 Summary: tail -F should attempt to read from old file until
EOF is encountered
                 Project: GNU Core Utilities
            Submitted by: josb
            Submitted on: Saturday 08/16/2008 at 07:53
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any



Currently when `tail -F filename' sees that `filename' was moved (by noticing
the dev/ino combo changing), it immediately switches to reading from the new
filename without making a last attempt to read from the old file. When tailing
log files this will cause tail to miss data in the usual scenario where the
old file is closed, moved and the new file opened with the same name. The
moment the new file appears, writing will have stopped to the old file, as
close() has mostly likely been called and any remaining data will have been
flushed to disk. So there is a good chance that reading until EOF from the old
file will yield the file's remainder.

This patch was stress-tested against coreutils-6.4 and daemontools' multilog
on CentOS 4, in a setup that forced multilog to rotate files rapidly and that
checked for gaps in the logging stream from tail using a sequence number. In
all but the most extreme scenarios (where the file was being rotated multiple
times per second), this patch virtually eliminated data loss.

A similar patch was committed to FreeBSD; see
http://www.freebsd.org/cgi/query-pr.cgi?pr=101979&cat=bin for details and a
description of the test setup.


File Attachments:

Date: Saturday 08/16/2008 at 07:53  Name: tail-dump_remainder.patch  Size:
321B   By: josb
Patch implementing this feature


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]