From 63e141807ec91640b61fdf95b33b75926cd5f4f6 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Thu, 26 Jan 2023 09:46:46 +0900 Subject: [PATCH 1/2] buffer: warning message for restoring buffer with flush_at_shutdown Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/buf_file.rb | 6 +++++- lib/fluent/plugin/buf_file_single.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fluent/plugin/buf_file.rb b/lib/fluent/plugin/buf_file.rb index 4725f5c9fe..de8a22e0e6 100644 --- a/lib/fluent/plugin/buf_file.rb +++ b/lib/fluent/plugin/buf_file.rb @@ -145,7 +145,11 @@ def resume Dir.glob(escaped_patterns(patterns)) do |path| next unless File.file?(path) - log.debug { "restoring buffer file: path = #{path}" } + if owner.respond_to?(:buffer_config) && owner.buffer_config&.flush_at_shutdown + log.warn { "restoring buffer file: path = #{path}" } + else + log.debug { "restoring buffer file: path = #{path}" } + end m = new_metadata() # this metadata will be overwritten by resuming .meta file content # so it should not added into @metadata_list for now diff --git a/lib/fluent/plugin/buf_file_single.rb b/lib/fluent/plugin/buf_file_single.rb index 225447063e..600f8945f6 100644 --- a/lib/fluent/plugin/buf_file_single.rb +++ b/lib/fluent/plugin/buf_file_single.rb @@ -166,7 +166,11 @@ def resume Dir.glob(escaped_patterns(patterns)) do |path| next unless File.file?(path) - log.debug { "restoring buffer file: path = #{path}" } + if owner.respond_to?(:buffer_config) && owner.buffer_config&.flush_at_shutdown + log.warn { "restoring buffer file: path = #{path}" } + else + log.debug { "restoring buffer file: path = #{path}" } + end m = new_metadata() # this metadata will be updated in FileSingleChunk.new mode = Fluent::Plugin::Buffer::FileSingleChunk.assume_chunk_state(path) From 0807567b538f39db5a6e9be9e87b94f9c269f6e0 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 27 Jan 2023 13:49:06 +0900 Subject: [PATCH 2/2] add comment for the intention of warning Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/buf_file.rb | 2 ++ lib/fluent/plugin/buf_file_single.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/fluent/plugin/buf_file.rb b/lib/fluent/plugin/buf_file.rb index de8a22e0e6..70e086d40d 100644 --- a/lib/fluent/plugin/buf_file.rb +++ b/lib/fluent/plugin/buf_file.rb @@ -146,6 +146,8 @@ def resume next unless File.file?(path) if owner.respond_to?(:buffer_config) && owner.buffer_config&.flush_at_shutdown + # When `flush_at_shutdown` is `true`, the remaining chunk files during resuming are possibly broken + # since there may be a power failure or similar failure. log.warn { "restoring buffer file: path = #{path}" } else log.debug { "restoring buffer file: path = #{path}" } diff --git a/lib/fluent/plugin/buf_file_single.rb b/lib/fluent/plugin/buf_file_single.rb index 600f8945f6..1d974962a7 100644 --- a/lib/fluent/plugin/buf_file_single.rb +++ b/lib/fluent/plugin/buf_file_single.rb @@ -167,6 +167,8 @@ def resume next unless File.file?(path) if owner.respond_to?(:buffer_config) && owner.buffer_config&.flush_at_shutdown + # When `flush_at_shutdown` is `true`, the remaining chunk files during resuming are possibly broken + # since there may be a power failure or similar failure. log.warn { "restoring buffer file: path = #{path}" } else log.debug { "restoring buffer file: path = #{path}" }