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

Add option to check queued? loosely #2564

Merged
merged 2 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
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
22 changes: 15 additions & 7 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,12 @@ def queued_records
synchronize { @queue.reduce(0){|r, chunk| r + chunk.size } }
end

def queued?(metadata=nil)
synchronize do
if metadata
n = @queued_num[metadata]
n && n.nonzero?
else
[email protected]?
def queued?(metadata = nil, optimistic: false)
if optimistic
optimistic_queued?(metadata)
else
synchronize do
optimistic_queued?(metadata)
end
end
end
Expand Down Expand Up @@ -739,6 +738,15 @@ def statistics

private

def optimistic_queued?(metadata = nil)
if metadata
n = @queued_num[metadata]
n && n.nonzero?
else
[email protected]?
end
end

def add_timekey(t)
@mutex.synchronize do
@timekeys[t] += 1
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def emit_buffered(tag, es)
@counter_mutex.synchronize{ @emit_count += 1 }
begin
execute_chunking(tag, es, enqueue: (@flush_mode == :immediate))
if !@retry && @buffer.queued?
if !@retry && @buffer.queued?(nil, optimistic: true)
submit_flush_once
end
rescue
Expand Down