Error code

MySQL 1213

MYSQL1213
Database Error Code· An error code returned by a database server such as PostgreSQL or MySQL.

What it means

Deadlock found when trying to get lock — two transactions blocked each other.

How to fix it

  1. Retry the rolled-back transaction.
  2. InnoDB is designed for this — catch the error and retry.
  3. Ensure all transactions acquire locks in the same consistent order to prevent cycles.
  4. Reduce transaction scope and duration to minimize the window for conflicts.

Not affiliated with MySQL. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.