GitHub user davidmoten opened a pull request:

    https://github.com/apache/commons-io/pull/29

    [IO-528] fix Tailer.run race condition runaway logging

    `Tailer.run` has a race condition that can have serious effects. 
    
    The `run()` method has two while loops. The first waits till the file 
exists and the second loop reads lines from the file doing some file rotation 
checking on the way.  If the file is deleted while the second loop is in 
progress then the loop goes crazy logging warnings that look like this:
    
    `
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileRotated
    INFO: file rotated
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileNotFound
    WARNING: file not found
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileRotated
    INFO: file rotated
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileNotFound
    WARNING: file not found
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileRotated
    INFO: file rotated
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileNotFound
    WARNING: file not found
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileRotated
    INFO: file rotated
    Dec 06, 2016 1:02:18 AM com.github.davidmoten.logan.LogFile$1 fileNotFound
    WARNING: file not found
    `
    
    In our case this had serious effects. The file being tailed was deleted by 
another process and all available disk space was rapidly used up by the 
logging. This crashed a system.
    
    The fix is to put a sleep after the call to `fileNotFound()`.
    
    I haven't made a unit test because reliably triggering this problem would 
involve a major refactor of the `run` method to make it testable.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/davidmoten/commons-io 
fix-tailer-race-condition

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-io/pull/29.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #29
    
----
commit b6c13341564475f4b804ec8e46f665211236b7f7
Author: Dave Moten <[email protected]>
Date:   2017-02-01T03:54:00Z

    fix Tailer.run race condition runaway logging

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to