Skip to content

Commit

Permalink
in_tail: Care about concurrent key deletion
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom committed Mar 8, 2024
1 parent f1f7866 commit 8b15478
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ def detach_watcher_after_rotate_wait(tw, ino)

return if @tails_rotate_wait[tw]

@tails_rotate_wait[tw] = { ino: ino, timer: nil }

if throttling_is_enabled?(tw)
# When the throttling feature is enabled, it might not reach EOF yet.
# Should ensure to read all contents before closing it, with keeping throttling.
Expand All @@ -630,15 +632,17 @@ def detach_watcher_after_rotate_wait(tw, ino)
detach_watcher(tw, ino)
end
end
@tails_rotate_wait[tw] = { ino: ino, timer: timer }
else
# when the throttling feature isn't enabled, just wait @rotate_wait
timer = timer_execute(:in_tail_close_watcher, @rotate_wait, repeat: false) do
@tails_rotate_wait.delete(tw)
detach_watcher(tw, ino)
end
@tails_rotate_wait[tw] = { ino: ino, timer: timer }
end

# To avoid conflict with timer execution (It deletes the key concurrently)
v = @tails_rotate_wait[tw]
v[:timer] = timer if v
end

def flush_buffer(tw, buf)
Expand Down

0 comments on commit 8b15478

Please sign in to comment.