Uploaded image for project: 'Flume'
  1. Flume
  2. FLUME-3083

Taildir source can miss events if file updated in same second as file close

Agile BoardAttach filesAttach ScreenshotVotersStop watchingWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.7.0
    • 1.8.0
    • Sinks+Sources
    • None

    Description

      I suspect there is a scenario where the taildir source can miss reading events from a log file due to how the source determines whether a file has been updated. In ReliableTaildirEventReader:

      boolean updated = tf.getLastUpdated() < f.lastModified()
      ...
      tf.setNeedTail(updated);
      

      Consider this sequence of events from TaildirSource.process(). Assume they all happen within the same second and there is just a single log file.

      1. Call ReliableTaildirEventReader.updateTailFiles()
        • This call will set ReliableTaildirEventReader.updateTime to current time in milliseconds
        • Assume the underlying file has not been updated within the last idleTimeout milliseconds
      2. Due to idleness, the tail file's inode is added to TaildirSource.idleInodes in idleFileCheckerRunnable
      3. tf.needTail is false. Skip reading file.
      4. Underlying file is updated with events E1
      5. TaildirSource.closeTailFiles()
        • Call TaildirSource.tailFileProcess() before close to read any pending events
        • Events E1 are read and processed
        • Since events were read, call ReliableTaildirEventReader.commit() which updates the tail file's position and sets its last updated time to ReliableTaildirEventReader.updateTime from 1.a
        • Close file
      6. Events E2 are written to underlying file. File's modification time is in the same second as the tail file's last updated time.
      7. Since the time returned by File.lastModified() is the mtime in seconds converted to milliseconds the file's last modified time is less than the tail file's last updated time and taildir won't reopen the file to read E2.
        • This behaviour of File.lastModified() may be platform/jvm specific. I confirmed the behavior using OpenJDK 8 on Ubuntu precise.

      Can someone confirm this?

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            eskrm eskrm
            eskrm eskrm
            Votes:
            0 Vote for this issue
            Watchers:
            6 Stop watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment