-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporary gzip files are not removed when deleted #190
Comments
🤔 The In taking a closer look, it looks like we're creating the If this is the case, a separate workaround may be to simply replace diff --git a/lib/logstash/outputs/s3/temporary_file_factory.rb b/lib/logstash/outputs/s3/temporary_file_factory.rb
index 7695ac0..21a98ab 100644
--- a/lib/logstash/outputs/s3/temporary_file_factory.rb
+++ b/lib/logstash/outputs/s3/temporary_file_factory.rb
@@ -100,7 +100,7 @@ module LogStash
def initialize(file_io)
@file_io = file_io
- @gzip_writer = Zlib::GzipWriter.open(file_io)
+ @gzip_writer = Zlib::GzipWriter.new(file_io)
end
def path |
Excellent. Your patch works for me, and is much more elegant than my workarounds. |
Use `Zlib::GzipWriter::new(IO)` instead of `Zlib::GzipWriter::open(Object)`, since the latter effectively creates an additional file handle when passed an `IO`. This ensures that when we send `Zlib::GzipWriter#close`, the original `IO` is closed in turn. Resolves: logstash-plugins#190
Use `Zlib::GzipWriter::new(IO)` instead of `Zlib::GzipWriter::open(Object)`, since the latter effectively creates an additional file handle when passed an `IO`. This ensures that when we send `Zlib::GzipWriter#close`, the original `IO` is closed in turn. Resolves: logstash-plugins#190
Version
logstash-6.3.2 and logstash-7.0.0-alpha1-SNAPSHOT
Problem
Temporary gzip files are deleted before all file handlers to the files are closed, causing the filesystem to run out of space.
To replicate the issue, export an elasticsearch index to an S3 bucket with gzip encoding enabled. See configuration below. It is assumed that the temporary_directory variable has the default value /tmp/logstash.
While the export is running use lsof to list all files that are marked as deleted using the following command.
And watch the file system usage using the following commands:
Content of diskCheck.sh:
Workarounds
I was able to find two workarounds for the problem, but since I am not familiar with Ruby or the source code for S3 output I don't know if these solutions can cause other problems.
Workaround 1
Edit the file temporary_file_factory.rb and change line 87
from
to
Also, comment or remove the following code from line 102:
N.B.
I was not able to find any code that uses the file_io attribute, which is why I commented out line 102.
However, this might not be the best idea.
Workaround 2
Edit the file temporary_file_factory.rb and change line 98
from
to
Then add the following method to the IOWrappedGzip class.
The text was updated successfully, but these errors were encountered: