From 6e8bbde8129d30e7e3c68af52d5f7d09d43959ad Mon Sep 17 00:00:00 2001 From: msdata Date: Wed, 31 May 2023 14:14:35 +0800 Subject: [PATCH] Check inode expectation to detach correct watcher when follow_inodes Signed-off-by: Gary Zhu --- lib/fluent/plugin/in_tail.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index fb29dd249f..6c1d236df6 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -523,6 +523,11 @@ def update_watcher(target_info, pe) # so adding close_io argument to avoid this problem. # At shutdown, IOHandler's io will be released automatically after detached the event loop def detach_watcher(tw, ino, close_io = true) + if @follow_inodes && tw.ino != ino + log.warn("Skip detach_watcher because this is not the expected watcher to be detached", + path: tw.path, current_ino: tw.ino, expect_ino_to_close: ino) + return + end tw.watchers.each do |watcher| event_loop_detach(watcher) end