Skip to content
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

buffer: add log for time periods of restored chunks which may be broken #4028

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/fluent/plugin/buf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def persistent?
def resume
stage = {}
queue = []
exist_broken_file = false

patterns = [@path]
patterns.unshift @additional_resume_path if @additional_resume_path
Expand All @@ -158,6 +159,7 @@ def resume
begin
chunk = Fluent::Plugin::Buffer::FileChunk.new(m, path, mode, compress: @compress) # file chunk resumes contents of metadata
rescue Fluent::Plugin::Buffer::FileChunk::FileChunkError => e
exist_broken_file = true
handle_broken_files(path, mode, e)
next
end
Expand All @@ -182,6 +184,15 @@ def resume

queue.sort_by!{ |chunk| chunk.modified_at }

# If one of the files is corrupted, other files may also be corrupted and be undetected.
# The time priods of each chunk are helpful to check the data.
if exist_broken_file
log.info "Since a broken chunk file was found, it is possible that other files remaining at the time of resuming were also broken. Here is the list of the files."
(stage.values + queue).each { |chunk|
log.info " #{chunk.path}:", :created_at => chunk.created_at, :modified_at => chunk.modified_at
}
end

return stage, queue
end

Expand Down
11 changes: 11 additions & 0 deletions lib/fluent/plugin/buf_file_single.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def persistent?
def resume
stage = {}
queue = []
exist_broken_file = false

patterns = [@path]
patterns.unshift @additional_resume_path if @additional_resume_path
Expand All @@ -179,6 +180,7 @@ def resume
chunk = Fluent::Plugin::Buffer::FileSingleChunk.new(m, path, mode, @key_in_path, compress: @compress)
chunk.restore_size(@chunk_format) if @calc_num_records
rescue Fluent::Plugin::Buffer::FileSingleChunk::FileChunkError => e
exist_broken_file = true
handle_broken_files(path, mode, e)
next
end
Expand All @@ -193,6 +195,15 @@ def resume

queue.sort_by!(&:modified_at)

# If one of the files is corrupted, other files may also be corrupted and be undetected.
# The time priods of each chunk are helpful to check the data.
if exist_broken_file
log.info "Since a broken chunk file was found, it is possible that other files remaining at the time of resuming were also broken. Here is the list of the files."
(stage.values + queue).each { |chunk|
log.info " #{chunk.path}:", :created_at => chunk.created_at, :modified_at => chunk.modified_at
}
end

return stage, queue
end

Expand Down