RulesEngine quit due to exception
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
I suspect that there's a bug in eventlet that, once hit this edge-case, causes the rule-engine to go down:
2015-11-14 09:59:01,864 140360772253008 ERROR log [-] (PID:12405) RulesEngine quit due to exception.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/st2reactor/cmd/rulesengine.py", line 46, in _run_worker
return timer_thread.wait() and rules_engine_worker.wait()
File "/usr/local/lib/python2.7/dist-packages/eventlet/greenthread.py", line 175, in wait
return self._exit_event.wait()
File "/usr/local/lib/python2.7/dist-packages/eventlet/event.py", line 121, in wait
return hubs.get_hub().switch()
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 294, in switch
return self.greenlet.switch()
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 346, in run
self.wait(sleep_time)
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/poll.py", line 85, in wait
presult = self.do_poll(seconds)
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/epolls.py", line 62, in do_poll
return self.poll.poll(seconds)
File "/usr/lib/python2.7/dist-packages/st2common/signal_handlers.py", line 44, in handle_sigusr1
reopen_log_files(handlers=handlers)
File "/usr/lib/python2.7/dist-packages/st2common/logging/misc.py", line 50, in reopen_log_files
handler.release()
File "/usr/lib/python2.7/logging/__init__.py", line 705, in release
self.lock.release()
File "/usr/lib/python2.7/threading.py", line 203, in release
raise RuntimeError("cannot release un-acquired lock")
RuntimeError: cannot release un-acquired lock
2015-11-14 09:59:01,920 140360772253008 INFO base [-] Scheduler has been shut down
Potentially related issue:
http://stackoverflow.com/questions/23116383/thread-condition-variables-un-acquired-lock
Behavioral issue:
Once an exception was raise, from line 63 in our case:
https://github.com/StackStorm/st2/blob/master/st2reactor/st2reactor/cmd/rulesengine.py#L63
The default behavior is to shutdown the rule-engine:
https://github.com/StackStorm/st2/blob/master/st2reactor/st2reactor/cmd/rulesengine.py#L66
I suggest to either use the fail-fast approach and turn-off everything (i.e. st2ctl stop), or just print error to log and continue.
The problem with the current approach is that st2 remains up and running, so it keep processing events (the sensor is up and running) but the trigger cannot be passed to the rule-engine since it's down, so the events are not being handled, only that now it fails silently, which makes it harder to detect and fix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with st2reactor/cmd/rulesengine.py, especially _run_worker and the behavior around lines 63 and 66. Then read st2common/signal_handlers.py and st2common/logging/misc.py as shown in the traceback. Confirm how the exception affects the running services and define whether failure should stop everything or remain visible while processing continues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100