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

fluentd exits on SIGUSR1 if its logrotate feature is enabled #1951

Closed
abicky opened this issue Apr 17, 2018 · 1 comment · Fixed by #1957
Closed

fluentd exits on SIGUSR1 if its logrotate feature is enabled #1951

abicky opened this issue Apr 17, 2018 · 1 comment · Fixed by #1957
Labels
bug Something isn't working

Comments

@abicky
Copy link
Contributor

abicky commented Apr 17, 2018

Here is an example:

  • fluentd version: 59d9675
  • OS: macOS 10.13.4
% bundle exec ./bin/fluentd -c ./fluent.conf --log /tmp/fluent.log --log-rotate-age 1 --log-rotate-size 1024 &
[1] 4387
% kill -USR1 4387
Unexpected error wrong number of arguments (given 2, expected 0..1)
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/2.4.0/logger.rb:715:in `reopen'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:364:in `reopen!'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:163:in `supervisor_sigusr1_handler'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:137:in `block in install_supervisor_signal_handlers'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/process_manager.rb:252:in `select'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/process_manager.rb:252:in `tick'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/multi_spawn_server.rb:91:in `wait_tick'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/multi_worker_server.rb:60:in `run'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/multi_spawn_server.rb:57:in `run'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/server.rb:123:in `main'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/daemon.rb:119:in `main'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/serverengine-2.0.6/lib/serverengine/daemon.rb:68:in `run'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:606:in `supervise'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:476:in `run_supervisor'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/command/fluentd.rb:310:in `<top (required)>'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/bin/fluentd:8:in `require'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/bin/fluentd:8:in `<top (required)>'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:75:in `load'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:75:in `kernel_load'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:28:in `run'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:424:in `exec'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:27:in `dispatch'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:18:in `start'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/bin/bundle:30:in `block in <main>'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/bundler/friendly_errors.rb:122:in `with_friendly_errors'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/bin/bundle:22:in `<main>'
[arabiki@MBP-3:~/ghq/src/github.com/fluent/fluentd]
%
[1]  + exit 1     bundle exec ./bin/fluentd -c ./fluent.conf --log /tmp/fluent.log  1  1024

I've tried to fix the error by the following change:

diff --git a/lib/fluent/log.rb b/lib/fluent/log.rb
index 097216c3..30108510 100644
--- a/lib/fluent/log.rb
+++ b/lib/fluent/log.rb
@@ -625,5 +625,12 @@ module Fluent
         super
       end
     end
+
+    def reopen(path, mode)
+      if mode != 'a'
+        raise "Unsupported mode: #{mode}"
+      end
+      super(path)
+    end
   end
 end

However, I found another error...

% bundle exec ./bin/fluentd -c ./fluent.conf --log /tmp/fluent.log --log-rotate-age 1 --log-rotate-size 1024 &
[1] 5731
% kill -USR1 5731
Unexpected error can't be called from trap context
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/2.4.0/monitor.rb:187:in `lock'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/2.4.0/monitor.rb:187:in `mon_enter'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/2.4.0/monitor.rb:212:in `mon_synchronize'
  /Users/arabiki/.anyenv/envs/rbenv/versions/2.4.2/lib/ruby/2.4.0/logger.rb:719:in `reopen'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/log.rb:633:in `reopen'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:364:in `reopen!'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:163:in `supervisor_sigusr1_handler'
  /Users/arabiki/ghq/src/github.com/fluent/fluentd/lib/fluent/supervisor.rb:137:in `block in install_supervisor_signal_handlers'
(snip)
@abicky abicky changed the title fluentd exits by SIGUSR1 if its logrotate feature is enabled fluentd exits on SIGUSR1 if its logrotate feature is enabled Apr 17, 2018
@repeatedly
Copy link
Member

Thanks! Will check after japan container day.

@repeatedly repeatedly added the bug Something isn't working label Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants