Skip to content

Commit

Permalink
Prevent log input from sending duplicate messages due to file renaming (
Browse files Browse the repository at this point in the history
#21911) (#23743)

Input:Log: Reset TTL of registry state when a file is renamed. In some
rare cases the registry state is marked for removal (TTL is set to 0)
while the file is only renamed. Log detects the renaming of the file
and updates the name of the file. As the file still exists it should
also update the TTL of the renamed file.

(cherry picked from commit bb50d32)

Co-authored-by: William Deurwaarder <william.git@xs4all.nl>
  • Loading branch information
jsoriano and williamd67 committed Feb 1, 2021
1 parent 82da952 commit 3ba0b19
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions filebeat/input/log/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ func (p *Input) harvestExistingFile(newState file.State, oldState file.State) {
logp.Debug("input", "Updating state for renamed file: %s -> %s, Current offset: %v", oldState.Source, newState.Source, oldState.Offset)
// Update state because of file rotation
oldState.Source = newState.Source
oldState.TTL = newState.TTL
err := p.updateState(oldState)
if err != nil {
logp.Err("File rotation state update error: %s", err)
Expand Down

0 comments on commit 3ba0b19

Please sign in to comment.