diff --git a/lib/fluent/plugin/storage_local.rb b/lib/fluent/plugin/storage_local.rb index d6107efbb1..9fa88dfcb7 100644 --- a/lib/fluent/plugin/storage_local.rb +++ b/lib/fluent/plugin/storage_local.rb @@ -133,7 +133,7 @@ def save tmp_path = @path + '.tmp' begin json_string = Yajl::Encoder.encode(@store, pretty: @pretty_print) - open(tmp_path, 'w:utf-8', @mode){ |io| io.write json_string } + open(tmp_path, 'w:utf-8', @mode) { |io| io.write json_string; io.fsync } File.rename(tmp_path, @path) rescue => e log.error "failed to save data for plugin storage to file", path: @path, tmp: tmp_path, error: e