Saving job metadata that can be accessed on job retry

Hi,

I have an Oban job that includes multiple steps. If the job fails, I would like to save metadata to the job indicating which steps have already succeeded, so that the retried job can use that information to decide what to do upon retry.

I have used workflows before and could break this job into multiple workflow steps if required, but in this particular case, it feels like overkill. Instead, I’m hoping that I can simply save some metadata or “state” on the job.

Is this possible? Is there any reason why this would be a bad idea?

Thanks,
Justin

1 Like

Jobs are the smallest unit of work for Oban compositions. If the steps aren’t large enough to belong in a workflow, then I’d focus on making them idempotent rather than recording a progress indicator.

Is this possible? Is there any reason why this would be a bad idea?

It is possible, but you’d have to do it manually with Ecto. We don’t recommend that people modify job meta manually because there aren’t any guarantees about which keys Oban or Pro will use internally.

Thanks @sorentwo. That is helpful to know. I’ll proceed with converting this to a workflow.