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

reproduce worker termination race condition #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/poolboy_test_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ handle_call(die, _From, State) ->
handle_call(_Event, _From, State) ->
{reply, ok, State}.

handle_cast(die, State) ->
{stop, {error, died}, State};
handle_cast(_Event, State) ->
{noreply, State}.

Expand Down
24 changes: 23 additions & 1 deletion test/poolboy_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ pool_test_() ->
{<<"Recover from timeout without exit handling">>,
fun transaction_timeout_without_exit/0},
{<<"Recover from transaction timeout">>,
fun transaction_timeout/0}
fun transaction_timeout/0},
{<<"Worker death synchronisation">>,
fun async_worker_death/0}
]
}.

Expand All @@ -92,6 +94,26 @@ checkin_worker(Pid, Worker) ->
poolboy:checkin(Pid, Worker),
timer:sleep(500).

async_worker_death() ->
{ok, Pid} = new_pool(1, 0),
?assertEqual(
ok,
poolboy:transaction(
Pid,
fun(Worker) ->
gen_server:cast(Worker, die)
end)
),
?assertEqual(
ok,
poolboy:transaction(
Pid,
fun(Worker) ->
pool_call(Worker, check)
end)
).



transaction_timeout_without_exit() ->
{ok, Pid} = new_pool(1, 0),
Expand Down