Verk crashes if a bad worker name is provided
nitinstp23 opened this issue · 2 comments
nitinstp23 commented
When I enqueue a job to Verk
but provide a worker module that does not exists,
Verk fails multiple times and finally crashes the main process iex
.
Below is the log I see in iex
.
iex(6)> Verk.enqueue(%Verk.Job{queue: :priority, class: "BadWorker", args: [1,2], max_retry_count: 5})
{:ok, "541419188923213558"}
iex(7)> [info] BadWorker 541419188923213558 start
[debug] Job failed reason: %ArgumentError{message: "argument error"}
[info] BadWorker 541419188923213558 fail: 15 ms
[error] Manager terminating, reason: {{:badarg, [{:erlang, :binary_to_existing_atom, ["Elixir.BadWorker", :utf8], []}, {:elixir_aliases, :safe_concat, 1, [file: 'src/elixir_aliases.erl', line: 119]}, {Verk.RetrySet, :calculate_retry_at, 3, [file: 'lib/verk/retry_set.ex', line: 38]}, {Verk.RetrySet, :add, 3, [file: 'lib/verk/retry_set.ex', line: 20]}, {Verk.RetrySet, :add!, 3, [file: 'lib/verk/retry_set.ex', line: 34]}, {Verk.QueueManager, :handle_call, 3, [file: 'lib/verk/queue_manager.ex', line: 132]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 636]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 665]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}, {GenServer, :call, [:"priority.queue_manager", {:retry, %Verk.Job{args: [1, 2], class: "BadWorker", enqueued_at: 1511345653, error_backtrace: nil, error_message: nil, failed_at: nil, finished_at: nil, jid: "541419188923213558", max_retry_count: 5, original_json: "{\"retry_count\":0,\"retried_at\":null,\"queue\":\"priority\",\"max_retry_count\":5,\"jid\":\"541419188923213558\",\"finished_at\":null,\"failed_at\":null,\"error_message\":null,\"error_backtrace\":null,\"enqueued_at\":1511345653,\"class\":\"BadWorker\",\"args\":[1,2]}", queue: "priority", retried_at: nil, retry_count: 0}, 1511345653, %ArgumentError{message: "argument error"}, [{:erlang, :binary_to_existing_atom, ["Elixir.BadWorker", :utf8], []}, {:elixir_aliases, :safe_concat, 1, [file: 'src/elixir_aliases.erl', line: 119]}, {Verk.Worker, :handle_cast, 2, [file: 'lib/verk/worker.ex', line: 35]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 616]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 686]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}, 5000]}}
[error] GenServer #PID<0.717.0> terminating
** (stop) :failed
Last message: {:"$gen_cast", {:perform, %Verk.Job{args: [1, 2], class: "BadWorker", enqueued_at: 1511345653, error_backtrace: nil, error_message: nil, failed_at: nil, finished_at: nil, jid: "541419188923213558", max_retry_count: 5, original_json: "{\"retry_count\":0,\"retried_at\":null,\"queue\":\"priority\",\"max_retry_count\":5,\"jid\":\"541419188923213558\",\"finished_at\":null,\"failed_at\":null,\"error_message\":null,\"error_backtrace\":null,\"enqueued_at\":1511345653,\"class\":\"BadWorker\",\"args\":[1,2]}", queue: "priority", retried_at: nil, retry_count: 0}, #PID<0.708.0>}}
State: nil
[info] Queue Manager started for queue priority
[info] Workers Manager started for queue priority (running)
[info] Added 1 jobs.
[info] No more jobs to be added to the queue priority from inprogress list.
[info] BadWorker 541419188923213558 start
[debug] Job failed reason: %ArgumentError{message: "argument error"}
[info] BadWorker 541419188923213558 fail: 0 ms
[info] Queue Manager started for queue priority
[info] Application demo_app exited: shutdown
Let me know if such errors can be handled gracefully.
Thanks
edgurgel commented
The Verk.Supervisor is added by the user to the Application. The supervisor can be configured however you want. It can restart forever and never cause your application to restart etc.
defmodule Example.App do
use Application
def start(_type, _args) do
import Supervisor.Spec
tree = [supervisor(Verk.Supervisor, [])]
opts = [name: Simple.Sup, strategy: :one_for_one]
Supervisor.start_link(tree, opts)
end
end
You can read more about the options here: https://hexdocs.pm/elixir/1.5.2/Supervisor.Spec.html
nitinstp23 commented
Thanks @edgurgel