How Can I remove flow/task runs stuck in a running or canceling state?

This may happen after deleting a flow or flow run id resulting in errant flow/task runs that have not completely been removed from the system, more often than not these runs will clear on their own however in some cases it may be necessary to manually remove them.

How to find flow runs:

query{
 	flow_run(where: {state: {_eq:"Cancelling"}}) {
    name
    id
    state
    }
}

you can switch out flow_run for task_run and the state Cancelling for Running

Once you have those IDs run this query either through the interactive api or through the graphql client:

mutation setflowRunStates($input: [set_flow_run_state_input!]!) {
set_flow_run_states(input: {states: $input}) {
  states {
  id
  __typename
  }
  __typename
}
}

Query Input, you may also submit a list of flow/task runs in this format to delete several at one time:

{
      "input": {
        "flow_run_id": "fbca6355-a892-4c1c-bee8-1e1655bb718a",
        "version": 1,
        "state": {
          "type": "Cancelled",
          "message": "marked task run as Cancelled because \"because\""
        }
      }
}

Example Image of Interactive API to send in Email

2 Likes