Skip to content

Run TailWatcher#on_notify before attaching triggers#1261

Merged
repeatedly merged 1 commit intofluent:masterfrom
akihiro17:run-on-notify-before-attaching
Oct 5, 2016
Merged

Run TailWatcher#on_notify before attaching triggers#1261
repeatedly merged 1 commit intofluent:masterfrom
akihiro17:run-on-notify-before-attaching

Conversation

@akihiro17
Copy link
Contributor

@akihiro17 akihiro17 commented Oct 5, 2016

related to #1229

This commit runs TailWatcher#on_notify before attaching stat_trigger and timer_trigger and prevents TailWatcher#on_notify from running in two different threads(main and event loop thread) at the same time.

This change fixes the can't modify string; temporarily locked error.

I think fluentd v0.12 does not raise the can't modify string; temporarily locked error because it runs stat_trigger and timer_trigger after TailInput#start finishes and thus TailWatcher#on_notify is not executed in two threads simultaneously.

# fluentd v0.12
# in_tail.rb
def start
  @loop = Coolio::Loop.new
  refresh_watchers

  @thread = Thread.new(&method(:run))
end

def run
  @loop.run
end

reproduction steps

same as described in #1229

  1. Create large log files by using append.rb
  2. Remove a pos file (rm tmp/logs/tail.pos)
  3. Run fluentd
  4. Run append.rb on another terminal

This commit runs `TailWatcher#on_notify` before attaching `stat_trigger` and `timer_trigger` and prevents `TailWatcher#on_notify` from running in two different threads(main and event loop thread) at the same time.

This change fixes the `can't modify string; temporarily locked` error.

I think fluentd v0.12 does not raise the `can't modify string; temporarily locked` error because it runs `stat_trigger` and `timer_trigger` after `TailInput#start` finishes and   thus `TailWatcher#on_notify` is not executed in two threads simultaneously.

fluentd v0.12
in_tail.rb

```ruby
def start
  @loop = Coolio::Loop.new
  refresh_watchers

  @thread = Thread.new(&method(:run))
end

def run
  @loop.run
end
```
@repeatedly repeatedly merged commit 5fc798c into fluent:master Oct 5, 2016
@repeatedly
Copy link
Member

Thanks 👍
This seems the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants