ktayah

ktayah

Workflow.add_workflow/4 with deps: permanently suspends a sub-workflow's put_context job

Environment

  • Oban Pro: 1.7.6

  • Oban: 2.22.1

Issue

When a sub-workflow built with Workflow.put_context/2 is attached to a parent via add_workflow/4 with a non-empty deps:, the sub-workflow’s :context job gets stuck in suspended forever. Any downstream job that depends on the whole sub-workflow then never runs.

Code snippet to recreate issue:

defmodule MyMod do
  def do_work(_ctx) do
    IO.inspect("Did work")
  end

  def finish_work(_ctx) do
    IO.inspect("Finished work")
  end
end

sub_a =
  Workflow.new(workflow_name: "sub_a")
  |> Workflow.put_context(%{hello: "world"})
  |> Workflow.add_cascade(:work, &MyMod.do_work/1)

sub_b =
  Workflow.new(workflow_name: "sub_b")
  |> Workflow.put_context(%{hello: "world"})
  |> Workflow.add_cascade(:work, &MyMod.do_work/1)

  Workflow.new(workflow_name: "parent")
  |> Workflow.add_workflow(:a, sub_a, deps: [])      # context stays `completed`
  |> Workflow.add_workflow(:b, sub_b, deps: :a)   # context becomes `suspended` — forever
  |> Workflow.add_cascade(:finish, &MyMod.finish_work/1, deps: [:a, :b])
  |> Oban.insert_all()
  # :finish never becomes available, because :b context job is stuck suspended

Oban UI showing workflow stuck on the context step of sub-workflow b:

Root Cause:

Seems to be linked to the logic in oban/pro/workflow.ex:1729, the add_workflow/4 func and how it behaves with a subworkflow that contains put_context and deps, particularily on the conditional:

if deps != [] and meta_deps == [] do
  # ... put_hold(changeset)

This seems to be linked the context job being stuck in the suspended state.

We can currently work around this temporarily by mainly calling Cascade.new and avoiding the use of Workflow.put_context, but a fix would be appreciated.

Most Liked

sorentwo

sorentwo

Oban Core Team

Thanks for the excellent report and the minimal reproduction. There’s a fix on main and it will be in v1.7.7 later today.

Where Next?

Popular in Troubleshooting Top

Sinc
I tried to run mix deps.get and get this error: 11:33:16.611 \[error\] Task #PID<0.335.0> started from :hex_fetcher terminating \*...
New
lunipaws
while setting up my development enviroment I encountered an issue that I just haven’t been able to resolve after running mix phx.gen.cer...
New
bugnano
Hello everyone. I’m the author of GitHub - bugnano/wtransport-elixir: Elixir bindings for the WTransport WebTransport library · GitHub ,...
New
hyperoceanic
Having read the book, I’m keen to explore Ash a bit more, but I’m falling at the first hurdle - the creation of a new project. Here’s my...
New
ktayah
Environment Oban Pro: 1.7.6 Oban: 2.22.1 Issue When a sub-workflow built with Workflow.put_context/2 is attached to a parent via ...
New
tellemiller
We recently started running Oban with Oban Web on PostgreSQL (AWS RDS gp3) and noticed our oban_jobs buffer cache hit ratio sitting at 65...
New
rayex
For hex package islands_score the source @spec for function format/2 is as such: @spec format(t, keyword) :: :ok Why does it show on 4 ...
New
anotherpit
A graft inside another graft causes Oban.Pro.Workflow.status to recurse forever. oban_pro 1.7.5 defmodule App.NestedGraftRepro.Test do ...
New
Lotoen
Hi, I’m on Linux Mint 22.3 - Cinnamon 64-bit, and I encountered an error when trying to build an elixir phoenix container 577.1 Reading...
New
hakarabakara1
I have three modules, a Business which is associated Tags and Categories though join tables business_tags and business_categories. I inte...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48475 226
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement