Skip to content

Commit

Permalink
sort metadata to be locked, not to make dead locks w/ other threads
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Oct 21, 2017
1 parent 28f1f66 commit 32c5f58
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def write(metadata_and_data, format: nil, size: nil, enqueue: false)
chunks_to_enqueue = []

begin
metadata_and_data.each do |metadata, data|
# sort metadata to get lock of chunks in same order with other threads
metadata_and_data.keys.sort.each do |metadata|
data = metadata_and_data[metadata]
write_once(metadata, data, format: format, size: size) do |chunk, adding_bytesize|
chunk.mon_enter # add lock to prevent to be committed/rollbacked from other threads
operated_chunks << chunk
Expand Down

0 comments on commit 32c5f58

Please sign in to comment.