diff options
| author | Alexey Lebedeff <alebedev@mirantis.com> | 2016-04-22 16:52:42 +0300 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr> | 2016-04-26 16:51:49 +0200 |
| commit | 5fb86319c444d459dee3606d56fbde335382f26e (patch) | |
| tree | 143be685a9b15314c0d291aaad741c721fbe69aa /src | |
| parent | 9099f8b5579d8b8839384bec6c2897df16a6be7e (diff) | |
| download | rabbitmq-server-git-5fb86319c444d459dee3606d56fbde335382f26e.tar.gz | |
Improve notifications about damaged I/O subsystem
Follow-up to https://github.com/rabbitmq/rabbitmq-server/pull/747
It's the best thing that can be done. Without `exit` anything inside
rabbit could hang - most prone to it is the `start_app` action. Crashing
loudly will be helpful, because during 2016 there were at least 2
production investigations about that issue.
And here is the script that I was using for reproduction:
https://gist.github.com/binarin/edd4102b7262d53e2cf09c76d5ca8e9e
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_log.erl | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/rabbit_log.erl b/src/rabbit_log.erl index ed73a293ca..5b5468cab7 100644 --- a/src/rabbit_log.erl +++ b/src/rabbit_log.erl @@ -96,7 +96,7 @@ with_local_io(Fun) -> Node = node(), case node(GL) of Node -> Fun(); - _ -> set_group_leader_to_user(), + _ -> set_group_leader_to_user_safely(whereis(user)), try Fun() after @@ -104,10 +104,12 @@ with_local_io(Fun) -> end end. -set_group_leader_to_user() -> - case whereis(user) of - undefined -> - warning("the 'user' I/O process has terminated, some features will fail until Erlang VM is restarted"); - User -> - group_leader(User, self()) - end. +set_group_leader_to_user_safely(undefined) -> + handle_damaged_io_system(); +set_group_leader_to_user_safely(User) when is_pid(User) -> + group_leader(User, self()). + +handle_damaged_io_system() -> + Msg = "Erlang VM I/O system is damaged, restart needed~n", + io:format(standard_error, Msg, []), + exit(erlang_vm_restart_needed). |
