poolboy
poolboy copied to clipboard
Fix premature exit
I met a lot of the following error logs when I execute init:stop()
14:46:29.924 [error] Undefined:Undefined gen_server <0.1199.0> terminated with reason: killed
14:46:29.924 [error] Undefined:Undefined CRASH REPORT Process <0.1199.0> with 0 neighbours exited with reason: killed in gen_server:decode_msg/9 line 432
And terminate function of mysql_conn.erl didn't get fully executed.
I have a pool size of 1600, maybe this caused this problem to be obvious.
Because exit(State#state.supervisor, shutdown) is async shutdown, the pool process passed away immediately,
so State#state.supervisor gets also killed,
Now that parent of all workers is dead, so workers show messages pasted above(gen_server:decode_msg/9 line 432),
So we need to wait a little bit to allow workers to terminate properly.