Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-528

Tailer.run race condition runaway logging

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.6
    • Utilities
    • None

    Description

      `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()`.

      This problem was raised in IO-398 three years ago but no change was made to the code base.

      PR submitted via github repo.

      Attachments

        Issue Links

          Activity

            People

              pascalschumacher Pascal Schumacher
              davidmoten2 Dave Moten
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: