From 51a88e1b1ebbcea74042b1d1c1b4526fb3a22dbe Mon Sep 17 00:00:00 2001 From: Rishie Sharma Date: Tue, 23 Mar 2021 06:36:05 +0100 Subject: [PATCH] Fix: occasional sincedb write issue on Windows machines (#283) On Windows servers we occasionally get exceptions `unknown IOException: java.io.IOException: The handle is invalid` when writing to sincedb file which crashes the plugin and somehow messes with the sincedb file which results in old log files being reprocessed causing duplicates. This change eliminates those exceptions. --- CHANGELOG.md | 3 +++ lib/filewatch/sincedb_collection.rb | 2 +- logstash-input-file.gemspec | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d1b0d..e850de7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 4.2.4 + - Fix: sincedb_write issue on Windows machines [#283](https://github.com/logstash-plugins/logstash-input-file/pull/283) + ## 4.2.3 - Refactor: improve debug logging (log catched exceptions) [#280](https://github.com/logstash-plugins/logstash-input-file/pull/280) diff --git a/lib/filewatch/sincedb_collection.rb b/lib/filewatch/sincedb_collection.rb index b7dc19b..d053b27 100644 --- a/lib/filewatch/sincedb_collection.rb +++ b/lib/filewatch/sincedb_collection.rb @@ -232,7 +232,7 @@ def atomic_write(time) # @return expired keys def non_atomic_write(time) - IO.open(IO.sysopen(@full_path, "w+")) do |io| + File.open(@full_path, "w+") do |io| @serializer.serialize(@sincedb, io, time.to_f) end end diff --git a/logstash-input-file.gemspec b/logstash-input-file.gemspec index 97021de..7c0044b 100644 --- a/logstash-input-file.gemspec +++ b/logstash-input-file.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-input-file' - s.version = '4.2.3' + s.version = '4.2.4' s.licenses = ['Apache-2.0'] s.summary = "Streams events from files" s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"