Skip to main content

Fixed: "ERROR 1317 (70100): Query execution was interrupted" in MySQL

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

A statement that had been waiting ended suddenly with ERROR 1317 (70100): Query execution was interrupted. MySQL didn't give up by itself: another session stopped it with KILL QUERY. The statement had no effect, and the connection is fine.

What I Was Doing​

I was updating a product from the mysql client on MySQL 9.7.4 in Docker. The row was locked by another transaction, so the statement was waiting:

mysql: terminal B
UPDATE products SET QuantityOnHand = 48 WHERE Id = 3;

What I Expected​

It would wait for the row, and then go through.

What I Got​

Output
ERROR 1317 (70100): Query execution was interrupted

An UPDATE ending with ERROR 1317 (70100): Query execution was interrupted.

What I Checked​

Whether the change happened.

mysql: terminal B
SELECT Id, QuantityOnHand FROM products WHERE Id = 3;
Output
+----+----------------+
| Id | QuantityOnHand |
+----+----------------+
| 3 | 50 |
+----+----------------+
1 row in set (0.003 sec)

No: it's still 50. The connection answered normally, too.

Who stopped it. A root session had seen the wait, and ended the statement:

mysql: root session
KILL QUERY 182;

The KILL page says: "KILL QUERY terminates the statement the connection is currently executing, but leaves the connection itself intact."

Why It Happens​

KILL QUERY is the usual cause: a person, a monitoring tool or a script. It's a deliberate stop, unlike ERROR 3024, which starts with the same words and adds maximum statement execution time exceeded.

The Fix​

Find out why it was stopped, because the reason matters more than the error. Here, it was stuck behind a lock, so see what's holding the row, and end that. Then run the statement again.

If you're in a transaction, decide what to do with it: the statements before this one are still pending, so COMMIT or ROLLBACK deliberately.

After the Fix​

With the other transaction finished, the same statement runs:

Output
mysql> UPDATE products SET QuantityOnHand = 48 WHERE Id = 3;
Query OK, 1 row affected (0.004 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT Id, QuantityOnHand FROM products WHERE Id = 3;
+----+----------------+
| Id | QuantityOnHand |
+----+----------------+
| 3 | 48 |
+----+----------------+
1 row in set (0.002 sec)

The same UPDATE succeeding in 0.004 seconds, and a SELECT showing the new quantity of 48.

Common Mistakes​

MistakeWhat happensDo this instead
Retrying right awayIt waits behind the same lockDeal with the blocker first
Assuming the transaction endedIt's still openCommit or roll back
Confusing it with ERROR 3024That's a time limit, not a personRead the whole message

Troubleshooting​

SymptomLikely causeFix
It happens at regular intervalsA tool that kills slow queriesCheck your monitoring
It happens from .NET as a NullReferenceExceptionMySql.Data's handling of this errorThe fix
ERROR 2013: Lost connection insteadA full KILLThe fix

Conclusion​

ERROR 1317 means something stopped your statement with KILL QUERY. The statement had no effect, and the connection and any open transaction are still there. Sort out why it was stuck, then run it again.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.