Hello <@ULVA73B9P>. I have a question about record...
# ask-marvin
a
Hello @Marvin. I have a question about records in the flow_run_state and task_run_state in prefect. It seems that the state of a specific flow are logged into those two tables at a specific interval. Is there a way to lengthen this interval as to be able to reduce the amount of records written to those tables. Moreover, if say a flow_run is stuck in a cancelling state, it seems that records continue to be written to those two tables even for months.
m
It seems I ran into an error attempting to determine the latest Prefect version and searching the documentation. Could you please confirm which version of Prefect you are using, either 2.x or 3.x? That way, I can look up the specific documentation and provide the most accurate assistance for your query.
a
@Marvin The version is 2.19.3
m
It seems there isn't a direct solution mentioned in the Prefect documentation to adjust the logging interval for
flow_run_state
and
task_run_state
to reduce the frequency of records. However, the behavior you're experiencing, especially with flows getting stuck in a "cancelling" state, might suggest some setup or infrastructure issues. Here are some general tips that might help you in dealing with these challenges: 1. Investigate Infrastructure Issues: If a flow is stuck in the "cancelling" state, check if there are any underlying infrastructure issues. Prefect's documentation points out that cancellation might fail if infrastructure blocks are altered or removed, or if there's a scope mismatch. You can read more about this in the Flows Concepts section. 2. State Change Hooks: While state change intervals are not directly adjustable, you can use state change hooks to manage actions when flows transition between states. This could include logging or additional error handling automation. You may find more information in the State Change Hooks Guide. 3. Flow Run Management: To ensure flows do not run indefinitely, consider implementing checks at various points in your flow to assess its progress and decide if it should continue or terminate. If the problem continues and heavily impacts your operations, consider reaching out to the Prefect community or support for more specialized assistance.
a
@Marvin so if a flow is stuck in cancelling status, is there a way to force it go into a cancelled state?
m
There don't seem to be any specific GitHub issues or documented methods for forcefully transitioning a flow that's stuck in the "cancelling" state to a "cancelled" state. However, here are some general suggestions you might try: 1. Check Infrastructure: Make sure the infrastructure the flow is running on is still accessible and properly configured. Issues at this level might prevent the flow from completing its cancellation. 2. Use APIs or Client: If you're comfortable with scripting, you might try using the Prefect Client API to programmatically update the state of the flow run. However, this requires a good understanding of Prefect's backend and state management system. 3. Temporary Workaround: If the above steps are not feasible, one temporary workaround would be to mark the flow run as "cancelled" in your own tracking or logging system, and consider it done from your operations standpoint until a more permanent solution can be found. For the most accurate advice, especially if this is causing significant issues, you might want to reach out directly to Prefect's support or community forums where more experienced users or developers might have encountered and solved similar issues.