Skip to content

Commit

Permalink
in_tail: Fix a stall bug on !follow_inode case
Browse files Browse the repository at this point in the history
Fix #3614

Although known stall issues of in_tail on `follow_inode` case are fixed
in v1.16.2, it has still a similar problem on `!follow_inode` case.

In this case, a tail watcher is possible to mark the position entry as
`unwatched` if it's tansitioned to `rotate_wait` state by
`refresh_watcher` even if another newer tail watcher is managing it.
It's hard to occur in usual because `stat_watcher` will be called
immediately after the file is changed  while `refresh_wather` is called
every 60 seconds by default. However, there is a rare possibility that
this order might be swapped especillay if in_tail is busy on processing
large amount of logs. Because in_tail is single threadied, event queues
such as timers or inotify will be stucked in this case.

There is no such problem on `follow_inode` case because position entries
are always marked as `unwatched` before entering `rotate_wait` state.

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Oct 18, 2023
1 parent 81d3da3 commit 6ce1bbb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def detach_watcher(tw, ino, close_io = true)

tw.close if close_io

if tw.unwatched && @pf
if @pf && tw.unwatched && (@follow_inode || !@tails[tw.path])
target_info = TargetInfo.new(tw.path, ino)
@pf.unwatch(target_info)
end
Expand Down

0 comments on commit 6ce1bbb

Please sign in to comment.