We had an interesting problem on our production servers that was caused by a single query that suddenly started misbehaving and taking an extraordinary amount of time.
Whilst a query is running, pages don’t time out due to a request timeout or stop processing when the user disconnects. So the net effect is a large number of headless queries running. This can (and did) cause havoc on the database server.
It looks like a known issue: [LDEV-1067] - Lucee
I’d like to find a generic way to stop an unexpected slow query causing havoc again.
I could use timeout on the cfquery but in the discussion on LDEV-1067, one person recommends against it. Is there a better way?
I’d prefer not to add a timeout on the datasource as some of the queries we run when everyone’s in bed are expected to take a long time.
I know that a properly designed schema with correct indexing and well-formulated queries is essential. We do that already! The execution plan for a query can change over time and mysql does not always make the best decisions. In my recent example, with two identical servers with identical database config and identical data: on one server the query completed in milliseconds, and on another server it did not complete in minutes - due to mysql choosing a different execution plan.
Thanks, Peter