Hello <@ULVA73B9P> The table flow_run_state and ta...
# ask-marvin
a
Hello @Marvin The table flow_run_state and task_run_state in the prefect database have a large dataset size for me. This is caused by flow_runs that are stuck in cancelling state. Since the Cancelling state is not a terminal state, records are constantly (forever) being written to those two tables. I was wondering, is it possible to decrease how often the state of a flow run is written to the flow_run_state table in prefect? Is this a configuration open to the user?
m
To provide you with the best possible guidance, I'll first need to identify the version of Prefect you are using, as configurations and features can vary between versions. Could you please confirm whether you are using Prefect 2.x or Prefect 3.x? If you're unsure, any additional context you can provide about your setup or environment could be helpful.
a
@Marvin prefect 2.19.3
m
It seems there isn't specific documentation or configuration in Prefect 2.x to directly control or reduce the frequency with which state updates are written to the
flow_run_state
and
task_run_state
tables. Typically, the frequency of these updates is tightly coupled with Prefect's internal mechanisms to track and manage the state of flow and task runs. This ensures accuracy and reliability in tracking the execution state of workflows. If flow runs are getting stuck in a "Cancelling" state, this might be an issue that needs to be addressed separately, possibly indicating a bug or misconfiguration in how your flows are being managed or terminated. Here are a couple of options to consider for managing this situation: 1. Investigate and Address Stuck Flows: Determine why your flows are stuck in a "Cancelling" state. This might involve more detailed inspection of logs or tracing back specific tasks that might be causing the hang-up. 2. Create a Maintenance Workflow: You could consider implementing a periodic script or flow that checks for flows stuck in an undesired state and handles them, perhaps by forcefully terminating them if necessary. This isn't inherently provided by Prefect but could be customized based on your needs. 3. Reach Out to Prefect Community or Support: If this is causing significant issues, consider reaching out on Prefect's community forums or their GitHub to see if there are workarounds or if this is a known issue being worked on. If you need more detailed help regarding stuck flows or configuration guidance, checking Prefect's community discussions or GitHub issues might provide further insights: Prefect Discussions or Prefect GitHub Issues.