Skip to content

File unexpectedly closes during tailing process #60

Open
@asra-eero

Description

@asra-eero

Describe the bug
We have a file that we're tailing where we're also interested in the file offset location. However, when we do t.Tell(), we sometimes run into the exception "err":"seek <filename>: file already closed"

Code:

	t, err := tail.TailFile(
		path,
		tail.Config{
			Follow:   true,
			ReOpen:   true,
		})

	for line := range t.Lines {
		// Fetch the current offset in the tailed file
		offset, err := t.Tell()
		// consume data
        } 

Has anyone else seen a similar issue with the file being closed? We've kind of solved this by adding a small wait and a retry in the t.Tell() function call, and that's resolved the issue, but we'd like to understand if this is a bug in the underlying tailing code where it's prematurely closing files.

System information

  • tail version: v1.4.8
  • OS: Ubuntu: 18.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions