How to Fix MySQL Error 3025 (ER_NON_RO_SELECT_DISABLE_TIMER)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 3025 when a read query changes data while using a timer. You fix it by removing data writes from your read query or dropping the timer. MySQL logs this issue with the symbol ER_NON_RO_SELECT_DISABLE_TIMER and the HY000 state. The server outputs the message that the select is not a read only statement. Then the database engine turns off the query timer for that specific run. Why mysql error 3025 happens in your database MySQL lets you set time limits on read queries. These

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 3025 when a read query changes data while using a timer. You fix it by removing data writes from your read query or dropping the timer.

MySQL logs this issue with the symbol ER_NON_RO_SELECT_DISABLE_TIMER and the HY000 state. The server outputs the message that the select is not a read only statement. Then the database engine turns off the query timer for that specific run.

Why mysql error 3025 happens in your database

MySQL lets you set time limits on read queries. These timers stop slow queries from locking up your database server. Still, the engine only enforces timers on pure read queries. If a query tries to change data, the timer cannot stop it mid-run. Stopping a write operation halfway through can corrupt tables or break replication.

You might wonder how a select statement can write data. This happens when your query calls a stored function that changes a table. A stored function might insert a log row or update a counter. When the select statement runs that function, it ceases to be read-only.

Triggers can also cause this behavior during complex query runs. Even setting session variables or locking tables inside a function can trigger this warning. When the database detects a write path, it protects your data first. It disables the timer and lets the statement finish without a time limit. The engine then returns code 3025 to warn your app.

How to find and fix the root cause in production

First, find the exact query that triggers the warning in your database logs. Look for select statements that use query timeout hints or session time limits. Inspect every function called inside the select list or the where clause.

Check the body of each stored function in your schema. Look for insert, update, or delete commands hidden inside those routines. Many teams put audit logging inside read functions by mistake. Move those write steps out of the stored function and into separate transactions.

Non-Human Identity Management + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Mark your pure read functions as read-only in their definitions. This helps the query planner verify that the routine does not change data. If a function must write data, do not call it inside timed select queries. Instead, run a stored procedure or handle the write step in your app code.

How to prevent timer warnings in shared databases

Data teams and devs often run ad-hoc queries against live databases. They set global or session timers so a bad query does not hurt production. When they hit this warning, their safety timer stops working right away. A slow function with a write step will keep running until it finishes.

To prevent this, separate your read roles from your write roles. Give analysts and reporting apps database roles that only allow pure reads. Do not grant them execute rights on functions that modify table data.

You should also review new stored routines before they reach production. Check that no team member adds table writes inside helper functions. When you also need to protect sensitive fields like emails or card numbers, use data masking. Masking rewrites matched fields in results without adding write steps to your database functions. Keep your queries clean so your safety timers always work as expected.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

Does MySQL error 3025 stop my query from running?

No, the database often treats this code as a warning rather than a hard crash. The engine disables the time limit and runs the statement until it finishes.

Can a session timeout setting trigger this error code?

Yes, setting a session read timeout applies to all select queries in that session. If any select query calls a function that writes data, you will see code 3025.

How do I keep a time limit on a query that calls functions?

Remove all data changes from the stored function so it only reads rows. Once the function is read-only, the database will keep the query timer active.

The query runs. The emails stay hidden.