InnoDB SELECT … FOR UPDATE statement locking all rows in a table

前端 未结 3 1977
無奈伤痛
無奈伤痛 2021-02-04 14:24

MySQL Server version 5.1.41 with InnoDB plugin enabled. I have the following three tables for invoices: invoices, invoice_components and invoice_expenses. Table invoices has inv

3条回答
  •  终归单人心
    2021-02-04 15:05

    You are using a transaction; autocommit does not disable transactions, it just makes them automatically commit at the end of the statements that do not have an explicit start transaction on them.

    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. Ideally do this on a quiet test-machine.

提交回复
热议问题