I have a strange situation, two identicaly conflicting queries (made by throw different application thread to the same record). The second one will fail with a DeadLock error.
The query is a very simple UPDATE table SET unindexedColum=1 WHERE pk=X
Checking the application and the inno status, the first (winning) query has a "S" lock, the second a "X" lock. But application did not explicitly open that lock.
Is it possibile that a lock is made automatically by application or by InnoDB?
The application is a Java app with Spring - JDBC.
Mysql handle lock row himself no need to manage lock at row on application. Just manage transaction on application.
Depending of you innodb configuration https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html
MySQL will handle locks on rows with different strategy, but default REPEATABLE READ.
Maybe you need to select the row you want to update with "select for update" https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html in a transaction to be clean, and use exception in application side if there is a deadlock.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.