Skip to content

Commit

Permalink
Lock the buffer during selecting metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
abicky committed Oct 23, 2017
1 parent 83e5d16 commit 990cbea
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,15 @@ def enqueue_unstaged_chunk(chunk)
def enqueue_all
log.trace "enqueueing all chunks in buffer", instance: self.object_id
if block_given?
synchronize{ @stage.keys }.each do |metadata|
chunk = @stage[metadata]
next unless chunk
v = yield metadata, chunk
enqueue_chunk(metadata) if v
metadata_array = []
synchronize do
@stage.each do |metadata, chunk|
v = yield metadata, chunk
metadata_array << metadata if v
end
end
metadata_array.each do |metadata|
enqueue_chunk(metadata)
end
else
synchronize{ @stage.keys }.each do |metadata|
Expand Down

0 comments on commit 990cbea

Please sign in to comment.