<div dir="ltr">Hi,<div><br></div><div>I have following code</div><div><br></div><div><a href="https://pastebin.com/rQE1t1XA">https://pastebin.com/rQE1t1XA</a> (order_manager.erl)<br><br>and </div><div><br></div><div><a href="https://pastebin.com/ruGvGEKS">https://pastebin.com/ruGvGEKS</a> (example_worker.erl)<br></div><div><br></div><div><font face="courier new, monospace">order_manager:create_order(poolnameany)</font> will create 10 worker processes, under supervisor named <font face="courier new, monospace">poolnameany</font>. Each worker processes is spawn of example_worker.erl</div><div><br></div><div><font face="courier new, monospace">order_manager:cast_order(poolnameany) </font>will sending / distributing message to all of worker processes in paralalel. So all 10 worker processes will receive same message content.</div><div><br></div><div>In example_worker.erl have following lines of code part:<br><br><font face="courier new, monospace">%% example_worker.erl<br>-define(SLEEP_RANDOM, [3000, 4000, 5000, 6000, 2000]).<br><br>pick_random_sleep() -><br> Res = lists:nth(rand:uniform(5), ?SLEEP_RANDOM),<br> Res.</font></div><div><font face="courier new, monospace">...</font></div><div><font face="courier new, monospace">...</font></div><div><font face="courier new, monospace">...</font></div><div><font face="courier new, monospace">handle_call({receive_initial_order, Ref, InitialOrders}, _From, State) -><br> io:format("~p is receiving: ~p~n", [self(), InitialOrders]),<br> timer:sleep(pick_random_sleep()),<br> {reply, {ok, self(), Ref}, State#state{offset=3}};</font><br></div><div><br></div><div>My problem is, i am not able to get reply completely from all 10 worker processes. Why?</div><div>I always only get 5 or 8 reply from 5 or 8 worker processes. 8 often.</div><div><br></div><div>And, this is the handler to receive reply from each worker processes</div><div><br></div><div><font face="courier new, monospace">buzz(_N, 11, _PoolName, _InitialOrders) -><br> ok;<br><br>buzz(N, Incr, PoolName, InitialOrders) -><br> spawn(fun() -><br> poolboy:transaction(<br> PoolName,<br> fun(Worker) -><br> Ref = make_ref(),<br> {ok, WorkerPid, Ref} = gen_server:call(Worker, {receive_initial_order, Ref, InitialOrders}),<br> io:format("Reply: [WorkerPid: ~p], [Ref: ~p]~n", [WorkerPid, Ref])<br> end<br> )<br> end),<br> buzz(N, Incr+1, PoolName, InitialOrders).</font><br></div><div><br></div><div><div><img src="cid:ii_jxjqn7dx0" alt="Screen Shot 2019-07-01 at 10.02.02.png" width="506" height="324"><br></div></div><div><br></div><div><br></div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Eshell V10.2<span class="gmail-Apple-converted-space"> </span>(abort with ^G)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(219,39,218)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">1> </span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases (<a href="http://www.rebar3.org/docs/releases">http://www.rebar3.org/docs/releases</a>)</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(57,192,38)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">===> Booted sasl</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(57,192,38)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">===> Booted wx</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(57,192,38)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">===> Booted observer</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(57,192,38)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">===> Booted dist_procs_je_asane</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">1> order_manager:create_order(balihome).</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">ok</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">2> order_manager:cast_order(balihome).</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.183.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.182.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.181.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.180.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.179.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.178.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.177.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">ok</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.176.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">3> <0.175.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><0.174.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.180.0>], [Ref: #Ref<0.2480760321.1800142849.332>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.183.0>], [Ref: #Ref<0.2480760321.1800142849.326>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.182.0>], [Ref: #Ref<0.2480760321.1800142849.328>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.176.0>], [Ref: #Ref<0.2480760321.1800142849.340>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.181.0>], [Ref: #Ref<0.2480760321.1800142849.330>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.179.0>], [Ref: #Ref<0.2480760321.1800142849.334>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.175.0>], [Ref: #Ref<0.2480760321.1800142849.342>]</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Reply: [WorkerPid: <0.178.0>], [Ref: #Ref<0.2480760321.1800142849.336>]</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p></div><div><br></div><div>Please enlightenment </div><div><br></div><div>Thank you</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>