From b8315c7a232f3df60ffab2150fd890e5fe44521c Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 8 Mar 2024 14:58:32 +0900 Subject: [PATCH] in_tail: Make closing io handler be done in closing phase Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/in_tail.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index e4866e157b..f6f12441b7 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -269,7 +269,7 @@ def shutdown # during shutdown phase, don't close io. It should be done in close after all threads are stopped. See close. stop_watchers(existence_path, immediate: true, remove_watcher: false) @tails_rotate_wait.keys.each do |tw| - detach_watcher(tw, @tails_rotate_wait[tw][:ino]) + detach_watcher(tw, @tails_rotate_wait[tw][:ino], false) end @pf_file.close if @pf_file @@ -279,6 +279,7 @@ def shutdown def close super # close file handles after all threads stopped (in #close of thread plugin helper) + # It may be because we need to wait IOHanlder.ready_to_shutdown() close_watcher_handles end @@ -520,6 +521,9 @@ def close_watcher_handles tw.close end end + @tails_rotate_wait.keys.each do |tw| + tw.close + end end # refresh_watchers calls @tails.keys so we don't use stop_watcher -> start_watcher sequence for safety.