diff --git a/lib/fluent/plugin/output.rb b/lib/fluent/plugin/output.rb
index ca3d50ea0c..61c5f27a9f 100644
--- a/lib/fluent/plugin/output.rb
+++ b/lib/fluent/plugin/output.rb
@@ -372,6 +372,13 @@ def configure(conf)
buf_type = Plugin.lookup_type_from_class(@buffer.class)
log.warn "'flush_at_shutdown' is false, and buffer plugin '#{buf_type}' is not persistent buffer."
log.warn "your configuration will lose buffered data at shutdown. please confirm your configuration again."
+ else
+ if Fluent.windows? && @buffer.persistent?
+ service_timeout = read_wait_to_kill_service_timeout
+ if service_timeout && service_timeout <= 5000 # default value might varies on windows client/server
+ log.warn "your WaitToKillServiceTimeout=#{service_timeout} registry configuration seems too short. Recommend to extend that value not to corrupt flushing buffer with forcibly shutdown"
+ end
+ end
end
if (@flush_mode != :interval) && buffer_conf.has_key?('flush_interval')
@@ -418,6 +425,22 @@ def configure(conf)
self
end
+ def read_wait_to_kill_service_timeout
+ if Fluent.windows?
+ begin
+ require "win32/registry"
+ Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Control",
+ Win32::Registry::KEY_READ) do |reg|
+ reg["WaitToKillServiceTimeout"].to_i
+ end
+ rescue => e
+ log.warn "'flush_at_shutdown' is true, but can't check WaitToKillServiceTimeout registry configuration", error: e
+ end
+ else
+ nil # not supported
+ end
+ end
+
def keep_buffer_config_compat
# Need this to call `@buffer_config.disable_chunk_backup` just as before,
# since some plugins may use this option in this way.
diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb
index 4eb295f0b7..30eda167f7 100644
--- a/test/command/test_fluentd.rb
+++ b/test/command/test_fluentd.rb
@@ -1760,4 +1760,22 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format
end
end
end
+
+ sub_test_case "test suspicious shorter service timeout on windows" do
+ test 'warn the default value of timekey (1d) is used as-is' do
+ omit "skip service timeout on windows test case" unless Fluent.windows?
+ conf_path = create_conf_file("warning.conf", <<~EOF)
+
+ config_include_dir ""
+
+
+ @type file
+ path #{@tmp_dir}/test.log
+ flush_at_shutdown
+
+ EOF
+ message="your WaitToKillServiceTimeout=5000 registry configuration seems too short. Recommend to extend that value not to corrupt flushing buffer with forcibly shutdown"
+ assert_log_matches(create_cmdline(conf_path, '--dry-run'), message)
+ end
+ end
end