You are utilising a transaction; autocommit merely causes transactions to commit automatically at the end of the statement; it does not stop transactions.
You may be updating every record in the database, therefore it’s possible that another thread is holding a record lock on a record for an excessively lengthy period of time, causing your thread to time out. Alternatively, you might do multiple (2+) UPDATE queries on the same row in the same transaction.
By sending a request for more information about the event, you
SHOW ENGINE INNODB STATUS
after the event (in SQL editor). Ideally do this on a quiet test-machine.
mysql> set innodb_lock_wait_timeout=100;
Query OK, 0 rows affected (0.02 sec)
mysql> show variables like ‘innodb_lock_wait_timeout’;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| innodb_lock_wait_timeout | 100 |
+————————–+——-+
Reset the lock at this point. If another transaction is locking yours, you have 100 seconds to SHOW ENGINE INNODB STATUS\G the database to find out which one it is.