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

Run TailWatcher#on_notify before attaching triggers #1261

Merged
merged 1 commit into from
Oct 5, 2016

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