lib/fluent/buffer.rb in fluentd-0.12.23 vs lib/fluent/buffer.rb in fluentd-0.12.24

- old
+ new

@@ -148,11 +148,11 @@ desc 'The size of each buffer chunk.' config_param :buffer_chunk_limit, :size, default: 8*1024*1024 desc 'The length limit of the chunk queue.' config_param :buffer_queue_limit, :integer, default: 256 desc 'The action when the size of buffer queue exceeds the buffer_queue_limit.' - config_param :buffer_queue_full_action, :enum, list: [:exception, :block], default: :exception + config_param :buffer_queue_full_action, :enum, list: [:exception, :block, :drop_oldest_chunk], default: :exception alias chunk_limit buffer_chunk_limit alias chunk_limit= buffer_chunk_limit= alias queue_limit buffer_queue_limit alias queue_limit= buffer_queue_limit= @@ -210,10 +210,13 @@ when :block # This is rough implementation. New Buffer API should improve this routine by using wait/signal $log.debug "buffer queue is full. Wait 1 second to re-emit events" sleep 1 retry + when :drop_oldest_chunk + $log.debug "buffer queue is full. Dropping oldest chunk" + pop(nil) end end if data.bytesize > @buffer_chunk_limit $log.warn "Size of the emitted data exceeds buffer_chunk_limit." @@ -324,10 +327,10 @@ end begin # #push(key) does not push empty chunks into queue. # so this check is nonsense... - if !chunk.empty? + if !chunk.empty? && !out.nil? write_chunk(chunk, out) end queue_empty = false @queue.synchronize do