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

Write buffer metadata into file ASAP #1628

Merged
merged 2 commits into from
Jul 21, 2017
Merged
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
6 changes: 4 additions & 2 deletions lib/fluent/plugin/buffer/file_chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ def write_metadata(update: true)
c: @created_at.to_i,
m: (update ? Time.now : @modified_at).to_i,
})
bin = msgpack_packer.pack(data).to_s
@meta.seek(0, IO::SEEK_SET)
@meta.truncate(0)
@meta.write(msgpack_packer.pack(data))
@meta.write(bin)
@meta.truncate(bin.bytesize)
end

def file_rename(file, old_path, new_path, callback=nil)
Expand Down Expand Up @@ -284,6 +285,7 @@ def create_new_chunk(path, perm)
@meta.set_encoding(Encoding::ASCII_8BIT)
@meta.sync = true
@meta.binmode
write_metadata(update: false)
rescue => e
# This case is easier than enqueued!. Just removing pre-create buffer file
@chunk.close rescue nil
Expand Down