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

Cigri fails to start with ruby 2.1: code is deadlockable #30

Open
bzizou opened this issue Jul 28, 2015 · 1 comment
Open

Cigri fails to start with ruby 2.1: code is deadlockable #30

bzizou opened this issue Jul 28, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@bzizou
Copy link
Contributor

bzizou commented Jul 28, 2015

Ruby 2 checks for deadlockable code and the way we are using signal handlers, with logging inside handlers is in this case:
log writing failed. can't be called from trap context
/usr/lib/ruby/2.1.0/monitor.rb:185:in lock': can't be called from trap context (ThreadError) from /usr/lib/ruby/2.1.0/monitor.rb:185:inmon_enter'
from /usr/lib/ruby/2.1.0/monitor.rb:209:in mon_synchronize' from /usr/lib/ruby/vendor_ruby/dbi.rb:231:inload_driver'
from /usr/lib/ruby/vendor_ruby/dbi.rb:149:in _get_full_driver' from /usr/lib/ruby/vendor_ruby/dbi.rb:134:inconnect'
from /usr/local/share/cigri/lib/cigri-iolib.rb:44:in db_connect' from /usr/local/share/cigri/lib/cigri-iolib.rb:1606:ininitialize'
from /usr/local/share/cigri/lib/cigri-eventlib.rb:78:in initialize' from /usr/local/share/cigri/modules/judas.rb:90:innew'
from /usr/local/share/cigri/modules/judas.rb:90:in notify' from /usr/local/share/cigri/modules/judas.rb:107:inblock in

'
from /usr/local/share/cigri/modules/judas.rb:113:in call' from /usr/local/share/cigri/modules/judas.rb:113:insleep'
from /usr/local/share/cigri/modules/judas.rb:113:in `'

A simple workaround should be to create a Thread for all logger inside a trap, but I'm not sure that it's clean:
Thread.new do
logger.debug("Spawned #{mod} process #{modpid}")
end

An interesting discussion about that: http://www.mikeperham.com/2013/02/23/signal-handling-with-ruby/

@bzizou bzizou added the bug label Jul 28, 2015
@bzizou bzizou self-assigned this Jul 28, 2015
@bzizou bzizou added this to the ASAP milestone Jul 28, 2015
@bzizou
Copy link
Contributor Author

bzizou commented Jul 29, 2015

We have to re-code completely the signal handling of the modules almighty and judas to implement "deferred signal handling".
A nice example may be found here: ddollar/foreman@5ab08c6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant