-- Find long-running queries SELECT id, user, time, state, info FROM information_schema.PROCESSLIST WHERE command != 'Sleep' AND time > 60; -- Kill one KILL QUERY <id>;
Almost six minutes. That single query was hogging the CPU, locking critical rows, and starving the checkout service.
Killing it was the only immediate option. No time for a graceful shutdown.
| Id | User | Host | db | Command | Time | State | Info | |----|------|------|----|---------|------|-------|------| | 19283 | app_user | 10.2.3.4:54321 | shop | Query | 347 | Sending data | SELECT * FROM orders o JOIN order_items oi ON o.id = oi.order_id JOIN products p ON oi.product_id = p.id WHERE o.created_at > '2023-01-01' AND p.tags LIKE '%summer%' |
The next morning, Maya added a monitoring alert for queries running longer than 60 seconds. She also taught the dev team how to catch themselves:
Almost instantly, CPU usage dropped from 98% to 12%. The API errors stopped. Her phone went quiet.