Skip to content

Commit

Permalink
Fix panic on fast file rotation
Browse files Browse the repository at this point in the history
This bug was introduce with elastic#2478 . The check for the second Stat receiving was missing. In case of very fast rotating file it could be that exactly at the time of Stat request the file is not existing anymore and an error is returned. The error was not checked.
  • Loading branch information
ruflin committed Sep 9, 2016
1 parent ddab579 commit 5656d44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions filebeat/prospector/prospector_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (p *ProspectorLog) getFiles() map[string]os.FileInfo {
// Fetch Lstat File info to detected also symlinks
fileInfo, err := os.Lstat(file)
if err != nil {
logp.Debug("prospector", "stat(%s) failed: %s", file, err)
logp.Debug("prospector", "lstat(%s) failed: %s", file, err)
continue
}

Expand All @@ -127,8 +127,12 @@ func (p *ProspectorLog) getFiles() map[string]os.FileInfo {
continue
}

// Fetch Stat file info which fetches the inode from the original and is used for comparison
// Fetch Stat file info which fetches the inode. In case of a symlink, the original inode is fetched
fileInfo, err = os.Stat(file)
if err != nil {
logp.Debug("prospector", "stat(%s) failed: %s", file, err)
continue
}

// If symlink is enabled, it is checked that original is not part of same prospector
// It original is harvested by other prospector, states will potentially overwrite each other
Expand Down

0 comments on commit 5656d44

Please sign in to comment.