Skip to content

Commit

Permalink
enqueue_chunk in chunk.synchronize may make deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed May 30, 2016
1 parent e2a7f43 commit ece0778
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def write_once(metadata, data, bulk: false, &block)
adding_bytesize = nil

chunk = synchronize { @stage[metadata] ||= generate_chunk(metadata) }
enqueue_list = []

chunk.synchronize do
# retry this method if chunk is already queued (between getting chunk and entering critical section)
Expand Down Expand Up @@ -402,7 +403,7 @@ def write_once(metadata, data, bulk: false, &block)
elsif bulk
# this metadata might be enqueued already by other threads
# but #enqueue_chunk does nothing in such case
enqueue_chunk(metadata)
enqueue_list << metadata
raise ShouldRetry
end
end
Expand All @@ -412,6 +413,9 @@ def write_once(metadata, data, bulk: false, &block)
write_step_by_step(metadata, data, data.size / 3, &block)
end
rescue ShouldRetry
enqueue_list.each do |metadata|
enqueue_chunk(metadata)
end
retry
end

Expand Down

0 comments on commit ece0778

Please sign in to comment.