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.

Showing Posts 1 to 1

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

edvardo1
Hello, I’ve found an interesting non-backwards-compatible change in Elixir 1.20. For context: There exists a project called PolyHok, whi...
New
andrewf
I’m using Postgrex in a Phoenix app to connect to Postgres. The database for my dev instance is in a local VM, with hostname jot.local. M...
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews