<div><span style="background-color:#fefefe;color:#1a1a1a;float:none;font-family:sans-serif;font-size:16px;font-style:normal;font-weight:400;text-decoration-style:initial;text-transform:none;white-space:normal;word-spacing:0px">gen_server:call has default timeout = 5000. Your spawned process in buzz function get from gen_server:call timeout error and than exit with bad match.<br />As it not linked or supervised, an error message is not printed.</span></div><div> </div><div>01.07.2019, 09:04, "I Gusti Ngurah Oka Prinarjaya" <okaprinarjaya@gmail.com>:</div><blockquote><div>Hi,<div> </div><div>I have following code</div><div> </div><div><a href="https://pastebin.com/rQE1t1XA">https://pastebin.com/rQE1t1XA</a> (order_manager.erl)<br /><br />and </div><div> </div><div><a href="https://pastebin.com/ruGvGEKS">https://pastebin.com/ruGvGEKS</a> (example_worker.erl)</div><div> </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> </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> </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></div><div> </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> </div><div>And, this is the handler to receive reply from each worker processes</div><div> </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></div><div> </div><div><div><img alt="Screen Shot 2019-07-01 at 10.02.02.png" height="324" src="cid:ii_jxjqn7dx0" width="506" /></div></div><div> </div><div> </div><div><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Eshell V10.2  (abort with ^G)</p><p style="color:rgb( 219 , 39 , 218 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><span style="color:#000000">1> </span>===> 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>)</p><p style="color:rgb( 57 , 192 , 38 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">===> Booted sasl</p><p style="color:rgb( 57 , 192 , 38 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">===> Booted wx</p><p style="color:rgb( 57 , 192 , 38 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">===> Booted observer</p><p style="color:rgb( 57 , 192 , 38 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">===> Booted dist_procs_je_asane</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;min-height:13px"> </p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">1> order_manager:create_order(balihome).</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">ok</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">2> order_manager:cast_order(balihome).</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.183.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.182.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.181.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.180.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.179.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.178.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.177.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">ok</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.176.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">3> <0.175.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px"><0.174.0> is receiving: [<<"Satu">>,<<"Dua">>,<<"Tiga">>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.180.0>], [Ref: #Ref<0.2480760321.1800142849.332>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.183.0>], [Ref: #Ref<0.2480760321.1800142849.326>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.182.0>], [Ref: #Ref<0.2480760321.1800142849.328>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.176.0>], [Ref: #Ref<0.2480760321.1800142849.340>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.181.0>], [Ref: #Ref<0.2480760321.1800142849.330>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.179.0>], [Ref: #Ref<0.2480760321.1800142849.334>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.175.0>], [Ref: #Ref<0.2480760321.1800142849.342>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px">Reply: [WorkerPid: <0.178.0>], [Ref: #Ref<0.2480760321.1800142849.336>]</p><p style="color:rgb( 0 , 0 , 0 );font-family:'menlo';font-size:11px;line-height:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;min-height:13px"> </p></div><div> </div><div>Please enlightenment </div><div> </div><div>Thank you</div><div> </div><div> </div><div> </div><div> </div><div> </div></div>,<p>_______________________________________________<br />erlang-questions mailing list<br /><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br /><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></p></blockquote>