File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -404,15 +404,20 @@ def restore_from_crash
404
404
under_recovery_files = get_under_recovery_files ( files )
405
405
406
406
files . each do |file_path |
407
- # if already recovering or recovered and uploading to S3, skip the files
408
- unless under_recovery_files . include? ( file_path )
407
+ # when encoding is GZIP, if file is already recovering or recovered and uploading to S3, log and skip
408
+ if under_recovery_files . include? ( file_path )
409
+ unless file_path . include? ( TemporaryFile . gzip_extension )
410
+ @logger . warn ( "The #{ file_path } file either under recover process or failed to recover before." )
411
+ end
412
+ else
409
413
temp_file = TemporaryFile . create_from_existing_file ( file_path , temp_folder_path )
410
414
if temp_file . size > 0
411
415
@logger . debug? && @logger . debug ( "Recovering from crash and uploading" , :path => temp_file . path )
412
416
@crash_uploader . upload_async ( temp_file ,
413
417
:on_complete => method ( :clean_temporary_file ) ,
414
418
:upload_options => upload_options )
415
419
end
420
+ # do not remove if Logstash tries to recover but fails
416
421
if @encoding != GZIP_ENCODING && temp_file . size != 0
417
422
clean_temporary_file ( temp_file )
418
423
end
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ def size
43
43
# so we dont have to deal with fsync
44
44
# if the file is close, fd.size raises an IO exception so we use the File::size
45
45
begin
46
+ # fd is nil when LS tries to recover gzip file but fails
47
+ return 0 unless @fd != nil
46
48
@fd . size
47
49
rescue IOError
48
50
::File . size ( path )
You can’t perform that action at this time.
0 commit comments