Skip to content
This repository

Little doc fix, plus potential fix for serious issue in case of checkout_blocks=true and long running workers #2

Merged
merged 2 commits into from over 2 years ago

3 participants

Nikolay Panov Devin Torres Andrew Thompson
Nikolay Panov
  1. Fixed pool spec in README file (it should be 'size' variable, not 'pool_size').
  2. Fixed bad behavior in case of checkout_blocks=true and long running workers:

E.g., I have created pool with some long-running workerks.
Now, I starting checking out those workers:

1> poolboy:checkout(pool1).

2> poolboy:checkout(pool1).

...
12> poolboy:checkout(pool1).

13> poolboy:checkout(pool1).
** exception exit: {timeout,{gen_fsm,sync_send_event,[pool1,checkout]}}
in function gen_fsm:sync_send_event/2

As you may see, when we have no more workers, the "poolboy:checkout(pool1)." is blocked for about 5 seconds, then it return timeout error and DROP ALL WORKERS. Why?
I have added timeout specification as 'infinity' which may resolve this issue.

Nikolay A. P... and others added some commits September 15, 2011
1. Fixed pool spec in README file (it should be 'size' variable, not …
…'pool_size').

2. Fixed bad behavior in case of checkout_blocks=true and long running workers.
d35583a
Andrew Thompson Ensure the worker supervisor terminates when you stop poolboy 055db72
Devin Torres
Owner

Looking into this...

Devin Torres devinus merged commit 055db72 into from September 30, 2011
Devin Torres devinus closed this September 30, 2011
Devin Torres devinus referenced this pull request from a commit September 30, 2011
Try to address issue #2 with an optional timeout paramenter on checko…
…ut (default: 5000)

Some people value the let-it-fail philosophy which would allow the pool to fail when it can't send the event in time. Others may want to mimic a wholly blocking interface with infinity.
261d5fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 3 authors.

Sep 15, 2011
1. Fixed pool spec in README file (it should be 'size' variable, not …
…'pool_size').

2. Fixed bad behavior in case of checkout_blocks=true and long running workers.
d35583a
Sep 21, 2011
Andrew Thompson Ensure the worker supervisor terminates when you stop poolboy 055db72
This page is out of date. Refresh to see the latest.
4  README.md
Source Rendered
@@ -27,7 +27,7 @@ Example Application
27 27
     {env, [
28 28
         {pools, [
29 29
             {pool1, [
30  
-                {pool_size, 10},
  30
+                {size, 10},
31 31
                 {max_overflow, 20},
32 32
                 {hostname, "127.0.0.1"},
33 33
                 {database, "db1"},
@@ -35,7 +35,7 @@ Example Application
35 35
                 {password, "abc123"}
36 36
             ]},
37 37
             {pool2, [
38  
-                {pool_size, 5},
  38
+                {size, 5},
39 39
                 {max_overflow, 10},
40 40
                 {hostname, "127.0.0.1"},
41 41
                 {database, "db2"},
5  src/poolboy.erl
@@ -14,7 +14,7 @@ checkin(Pool, Worker) ->
14 14
     gen_fsm:send_event(Pool, {checkin, Worker}).
15 15
 
16 16
 checkout(Pool) ->
17  
-    gen_fsm:sync_send_event(Pool, checkout).
  17
+    gen_fsm:sync_send_event(Pool, checkout, infinity).
18 18
 
19 19
 start_link(Args) ->
20 20
     case proplists:get_value(name, Args) of
@@ -148,7 +148,8 @@ handle_sync_event(get_avail_workers, _From, StateName, #state{workers=Workers}=S
148 148
 handle_sync_event(get_all_workers, _From, StateName, #state{worker_sup=Sup}=State) ->
149 149
   WorkerList = supervisor:which_children(Sup),
150 150
   {reply, WorkerList, StateName, State};
151  
-handle_sync_event(stop, _From, _StateName, State) ->
  151
+handle_sync_event(stop, _From, _StateName, #state{worker_sup=Sup}=State) ->
  152
+  exit(Sup, shutdown),
152 153
   {stop, normal, ok, State};
153 154
 handle_sync_event(_Event, _From, StateName, State) ->
154 155
   Reply = {error, invalid_message},
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.