Removing stuck processInstances in Camunda 8

I want to be able to remove all stuck processInstances.
I was hoping to use the DELETE command of the operate API.

But this gives me the following response

{
  "status": 400,
  "message": "Process instances needs to be in one of the states [COMPLETED, CANCELED]",
  "instance": "b9790279-ce2e-4dc6-a826-3cd9ba71ae90",
  "type": "Invalid request"
}

Why can I only delete Completed or Canceled flows.

How would I go about to delete my stuck instances then? Because they have the status ‘Active’
Is there something else in the Operate API I can use?

Any suggestions would be really helpful.

Hi @mvdveek,

Even if the process instances are stuck, they are still running.

You have to cancel the process instance via Zeebe-API first, before you can delete the history in Operate.

Hope this helps, Ingo

Hey @mvdveek

can we first clarify what do you mean with stuck? Is it stuck because some of your workers didn’t work anymore? Or is there an issue in zeebe and it makes no progress at all?

Greets
Chris

With stuck I mean a processInstance is waiting at a servicetask. We are still in active development. So it could mean no job worker has been implemented yet. Or a business exception has occured why it stays on the service task because we have not yet implemented boundary events to handle those exceptions

This sounds like a way forward. Thank you. We will look into this.