I occur Lock wait timeout exceeded error. below is exception:
org.springframework.dao.CannotAcquireLockException:
### Error updating database. Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
### The error may involve commManager.updateOrderHotelInfo-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:261)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
at $Proxy21.update(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:246)
spring transaction config
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
use Spring annotation @Transactional,it throw exception.but change to @Transactional(propagation=Propagation.REQUIRES_NEW) ,it is ok.
I execute show engine innodb status \G on MySqlServer ,output these: --TRANSACTION 107D2F81, ACTIVE 18 sec starting index read mysql tables in use 1, locked 1 LOCK WAIT 5 lock struct(s), heap size 1248, 3 row lock(s), undo log entries 1 MySQL thread id 23795, OS thread handle 0x50e8a940, query id 207416339 192.168.126.236 ppb Updating UPDATE commission_order_hotel_info_ext SET auditor_tel = '0898-88350052',
global_commission_percent = 10.00,
guarantee = '{\"type\":\"none\"}'
WHERE
hotel_id = 10190
Trx read view will not see trx with id >= 107D2F82, sees < 107D1795 ------- TRX HAS BEEN WAITING 18 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 3123 page no 3 n bits 128 index PRIMARY
of table hms
.commission_order_hotel_info_ext
trx id 107D2F81 lock_mode X waiting
TABLE LOCK table hms
.order_hotel_info
trx id 107D2F81 lock mode IX
RECORD LOCKS space id 2874 page no 16 n bits 1272 index uniq_hotel_id
of table hms
.order_hotel_info
trx id 107D2F81 lock_mode X locks rec but not gap
RECORD LOCKS space id 2874 page no 6 n bits 184 index PRIMARY
of table hms
.order_hotel_info
trx id 107D2F81 lock_mode X locks rec but not gap
TABLE LOCK table hms
.commission_order_hotel_info_ext
trx id 107D2F81 lock mode IX
RECORD LOCKS space id 3123 page no 3 n bits 128 index PRIMARY
of table hms
.commission_order_hotel_info_ext
trx id 107D2F81 lock_mode X waiting
---TRANSACTION 107D1795, ACTIVE 845 sec
5 lock struct(s), heap size 1248, 59 row lock(s), undo log entries 2
MySQL thread id 23819, OS thread handle 0x50dc7940, query id 207389624 192.168.126.83 ppb
Trx read view will not see trx with id >= 107D1796, sees < 107D1796
TABLE LOCK table hms
.order_hotel_info
trx id 107D1795 lock mode IX
RECORD LOCKS space id 2874 page no 16 n bits 1272 index uniq_hotel_id
of table hms
.order_hotel_info
trx id 107D1795 lock_mode X locks rec but not gap
RECORD LOCKS space id 2874 page no 44 n bits 232 index PRIMARY
of table hms
.order_hotel_info
trx id 107D1795 lock_mode X locks rec but not gap
TABLE LOCK table hms
.commission_order_hotel_info_ext
trx id 107D1795 lock mode IX
RECORD LOCKS space id 3123 page no 3 n bits 128 index PRIMARY
of table hms
.commission_order_hotel_info_ext
trx id 107D1795 lock_mode X
what steps to solve it