Lazy Loading in Environments Results in Unknown Worker #979
Labels
area:oss
Related to Oban OSS
closed:wontfix
This will not be worked on
kind:bug
Something isn't working
Precheck
I've googled extensively and this was the closest I could find to a similar issue https://elixirforum.com/t/problem-with-oban-workers/43634
Environment
elixir --version
): 1.12.2 & Erlang/OTP 24Current Behavior
I can insert multiple jobs with the same worker, but the jobs occasionally fail with unknown worker error on staging environment.
The error recorded in
oban_jobs
table isThe module definitely exists as some jobs with the same worker successfully execute. Following this step from the above ElixirForum link also confirms that the module is valid.
When inspecting the
oban_jobs
table data for the differences between the successful and errored jobs, I noticed that jobs attempted by the node with my machine name (I think local node? I'm not very familiar with OTP) successfully start, while the nodes namedelixir-node
fail.I dived into the Oban code and noted that the worker String to module conversion is done using
Module.safe_concat
, which (probably) indicates that the worker module was not loaded yet, causing the job to fail with unknown worker error.Based on our method of deployment, I think this issue would only occur locally/in staging and not in production (due to lazy module loading outside of
mix release
), however it would be great if the jobs' execution would not be flaky as it affects testing.Expected Behavior
Ensure the worker module is loaded before being determined and returned as unknown worker error.
The text was updated successfully, but these errors were encountered: