SELECT FOR UPDATE queries on flow_run table block for multiple seconds despite indexing
criticalperformanceUpdated Apr 24, 2025(via Exa)
How to detect:
Queries with FOR UPDATE locks on the flow_run table take 6+ seconds despite the table being indexed and containing only ~18k entries. The database shows no CPU, memory, or disk strain, suggesting lock contention or missing composite indexes.
Recommended action:
Investigate lock contention on flow_run table. Check for missing composite indexes that would optimize queries combining row locks with specific filters. Enable database vacuum service to prevent bloat. Review whether concurrent background services are creating lock conflicts. Consider upgrading to versions with PR #20940 fix (composite index on task_run(state_type, start_time)).