mysql Error Code: 1205 Lock wait timeout exceeded; try restarting transaction code example

Example: general error: 1205 lock wait timeout exceeded; try restarting transaction

You are using a transaction; autocommit does not disable transactions, it just makes them automatically commit at the end of the statement.

What is happening is, some other thread is holding a record lock on some record (you're updating every record in the table!) for too long, and your thread is being timed out.

You can see more details of the event by issuing a

SHOW ENGINE INNODB STATUS
after the event (in sql editor). Ideally do this on a quiet test-machine.

Tags:

Misc Example