devinus/poolboy — Issue #5: incorrect workers termination
Author: ddosia
Created: 2011-11-03 04:51:38+00:00
State: open

Hello, I have some troubles with workers termination. I successfully implemented worker, establish connection to my DB, all works fine.
Problem starts when you try to do application:terminate(myapp).
Terminate function in worker process begins to execute, but not ends. You can try to simulate it with such code:

```erlang
terminate(_Reason, #state{conn=Conn}) ->
io:format("BEFORE DISCONNECT ~n"),
% in all top supervisor i got 5000 timeout value
timer:sleep(2000),
io:format("AFTER DISCONNECT ~n"),
ok.

1> application:stop(myapp).
BEFORE DISCONNECT
ok
```

Sorry, i am Erlang novice, but afaik from supervisor docs:

> Important note on simple-one-for-one supervisors: The dynamically created child processes of a simple-one-for-one supervisor are not explic‐
> itly killed, regardless of shutdown strategy, but are expected to terminate when the supervisor does (that is, when an exit signal from the
> parent process is received).

Maybe this is the reason of such behaviour?
If it helps, my worker spawn new process, which talk with DB, and monitor it. During applicaion:stop process
it got such message: {'DOWN',#Ref<0.0.0.146>,process,<0.102.0>,killed}.