Oz Shaked
03/12/2025, 1:24 PM09:13:53.788 | WARNING | prefect.server.services.cancellationcleanup - CancellationCleanup took 47.755087 seconds to run, which is longer than its loop interval of 20.0 seconds.
Also the server is using a lot of CPU.Marvin
03/12/2025, 1:24 PMCancellationCleanup
service taking longer than its loop interval and the server's high CPU usage might be related to database locking. This can occur when the CancellationCleanup
service attempts to process a large number of flow or subflow runs, leading to prolonged database transactions.
To mitigate this, you can try the following:
1. Disable the Cancellation Cleanup Service: Set the environment variable PREFECT_API_SERVICES_CANCELLATION_CLEANUP_ENABLED
to false
. This should prevent the service from running and potentially locking the database.
2. Increase the Loop Interval: If disabling the service is not ideal, you can try increasing the loop interval by setting the environment variable PREFECT_API_SERVICES_CANCELLATION_CLEANUP_LOOP_SECONDS
to a higher value. However, note that this might not completely resolve the issue if the cleanup task itself is inherently long-running.
These steps are based on similar issues reported in the Prefect GitHub repository. For more details, you can refer to this GitHub issue.
If these steps don't resolve your issue, consider reviewing your flow structure and database configuration to identify any potential bottlenecks.Oz Shaked
03/12/2025, 1:37 PMMarvin
03/12/2025, 1:38 PMOz Shaked
03/12/2025, 1:40 PMMarvin
03/12/2025, 1:40 PMOz Shaked
03/12/2025, 1:49 PMMarvin
03/12/2025, 1:50 PMpg_repack
for PostgreSQL can help optimize performance.
For more information on managing and configuring Prefect's database, you can refer to the Prefect self-hosted documentation. If you need a more tailored solution, consider reaching out to Prefect support or consulting the community for best practices.