Closed bgentry closed 4 years ago
Ah, I think I've discovered the cause of this! 💡 It's Oban.insert_all
. Before calling Repo.insert_all
, it first calls Job.to_map/1
which only picks certain fields from the Job
structs it is inserting.
I can work on a PR though I'm not entirely certain which fields should/shouldn't be included in Job.to_map/1
or why it shouldn't be all of them.
I'm a bit surprised this hasn't been reported before. Then again, I don't know how often people use insert_all
compared to plain insert
.
Ah, I think I've discovered the cause of this! 💡 It's
Oban.insert_all
. Before callingRepo.insert_all
, it first callsJob.to_map/1
which only picks certain fields from theJob
structs it is inserting.
You're absolutely right. Well spotted.
I can work on a PR though I'm not entirely certain which fields should/shouldn't be included in
Job.to_map/1
or why it shouldn't be all of them.
The only field that can't be inserted is unique
, because it is virtual. Otherwise all of the fields should be acceptable. In fact, the @permitted
module attribute already has a list of the fields that are acceptable.
Precheck
Environment
v0.11.1
v11.5
Elixir & Erlang/OTP Versions (
elixir --version
)Current Behavior
I have a worker defined like this:
Note the
max_attempts: 3
, which AFAICT follows the instructions in the docs.In the only place in our code where I actually enqueue his job, I run:
Note that I am not explicitly setting
max_attempts
while enqueueing this job.Expected Behavior
Despite my only usage of
max_attempts
declaring that it should be 3 for this job, we have a bunch of failed instances of this job that have failed 15+ times and have amax_attempts: 20
set in the database (this query was run a bit after I deleted all instances with > 6 attempts):I'm not sure how this could have happened 🤔 Even when testing job creation on
iex
, I can see it appears to be settingmax_attempts
correclty:And yet, they sure seem to be resetting the
max_attempts
value. The best guess I have is that this is somehow being thrown away when the job is rescued due to it raising an exception (rather than cleanly erroring with{:error, err}
).