ktayah

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 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.

First Post! Switch mode

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.

— All posts loaded —

Where Next? Top

Trending in Troubleshooting Top

interpretive_scholar
I am trying to build a container for a new Phoenix app that I want to deploy in our kubernetes cluster. The container blows up when it ...
New
odix67
Hi, I have to build an app also on windows, since some time, I do not know it exactly, I ran into the the issue below during download of...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement