Open tomjoro opened 5 years ago
Sorry, forgot the test case:
test "bug" do
capture = ExUnit.CaptureIO.capture_io(fn ->
1..100
|> Enum.each(fn i ->
:ok = Que.add(NormalWorker, {:anything})
end)
end)
assert capture =~ ~r/failure/
end
You will get result:
1) test bug (LoadTest)
test/load_test.exs:28
Assertion with =~ failed
code: assert capture =~ ~r"failure"
left: ""
right: ~r/failure/
stacktrace:
test/load_test.exs:35: (test)
Thank you for reporting this issue. I'll look into this and try to come up with a reliable solution. Suggestions and PRs welcome!
I have just experienced the same problem. Slowing down perform()
with
Process.sleep(1000)
temporarily helped.
If I have a trivial Worker i.e. it completes really fast, then sometimes it will fail, when really it is a success. Here's my worker:
I think the problem is the worker process already completes before the Process.monitor is installed. In this case Erlang sends DOWN with info set to :noproc (and that's the error seen in failure too, since failure is handled by the second DOWN handling function in
lib/que/server.ex
I fixed it by add this function (between the two above) and then handling it as success.
def handle_info({:DOWN, ref, :process, _pid, :noproc}, queue) do
Note the:noproc
http://erlang.org/doc/man/erlang.html#monitor-2
I'd submit a pull request, but I don't think this is a good way to fix it, because the Worker might have failed. Is it possible to somehow do the Process.monitor at the same time the Worker is spawned, like
spawn_monitor
?