Hi everybody! It happens sometime that some flow r...
# ask-community
g
Hi everybody! It happens sometime that some flow runs are stuck in pending. Probably due to the amount of load they are forgotten. Is there a way we can somehow make the agent aware that these flow runs are still in pending? For example, would it work having a pipeline which just switches the state of this pending flow runs from pending to running?
b
Hi Giacomo! To clean up flow runs that are stuck in
Pending
, you could set up an automation which triggers if a run stays in
Pending
for more than "x" amount of time. The automation action could be to a) cancel the hanging flow run, and b) kick off a new flow run for that particular deployment. In theory you could change the flow run's state to
Running
with the automation action, but forcing that state may not work as intended. 🤔
g
cool! So what you suggest looks like what I was thinking. I was thinking to create another flow running every 1 or 2 hours and search for flow runs in pending status and move it to running or cancelling. I understand this would work then! The only part I would like to get more details is when you say
Copy code
you could set up an automation which triggers if a run stays in Pending for more than "x" amount of time
does this mean that Prefect can actively trigger a flow run based on events or do you mean to schedule a flow run every X hours and search for pending flow runs?
b
does this mean that Prefect can actively trigger a flow run based on events
^ yes 🙌
Trigger actions on events <- more on that here
g
only Prefect 3.0? Is it available in Prefect 2.19?
b
2 and 3!
g
cool! Thank you for the info, I will check it out!