Lock wait timeout exceeded; try restarting transaction
Ich auftreten Lock wait timeout exceeded error.
unten ist die Ausnahme:
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)
Frühjahr Transaktion config
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
nutzen Spring-annotation @Transactional,es zu werfen Ausnahme.aber ändern zu @Transactional(propagation=Propagation.REQUIRES_NEW) ,ist es ok.
Ich ausführen von show engine innodb status \G auf den MySqlServer ,diese Ausgabe:
--TRANSAKTION 107D2F81, AKTIV 18 sec ab index Lesen
mysql tables in use 1, gesperrt 1
SPERRE WARTEN Sie 5 lock struct(s), heap-Größe 1248, 3 row lock(s), undo-log-Einträge 1
Der MySQL thread id 23795, OS-thread-handle 0x50e8a940, query-id 207416339 192.168.126.236 ppb Aktualisieren
UPDATE commission_order_hotel_info_ext
SET auditor_tel = '0898-88350052',
global_commission_percent = 10.00,
guarantee = '{\"type\":\"none\"}'
WHERE
hotel_id = 10190
Trx lese-Ansicht nicht sehen trx mit id >= 107D2F82, sieht < 107D1795
------- TRX WARTET SEIT 18 SEC FÜR DIESES SCHLOSS GEWÄHRT WERDEN:
DATENSATZ SPERREN-space-id 3123 Seite 3 n bit 128-index PRIMARY
Tabelle hms
.commission_order_hotel_info_ext
trx-id 107D2F81 lock_mode X warten
TABLE LOCK table hms
.order_hotel_info
trx-id 107D2F81 Sperrmodus IX
DATENSATZ SPERREN-space-id 2874 Seite 16 n bits 1272 index uniq_hotel_id
Tabelle hms
.order_hotel_info
trx-id 107D2F81 lock_mode X-sperren rec aber keine Lücke
DATENSATZ SPERREN-space-id 2874 Seite 6 n bits 184 index PRIMARY
Tabelle hms
.order_hotel_info
trx-id 107D2F81 lock_mode X-sperren rec aber keine Lücke
TABLE LOCK table hms
.commission_order_hotel_info_ext
trx-id 107D2F81 Sperrmodus IX
DATENSATZ SPERREN-space-id 3123 Seite 3 n bit 128-index PRIMARY
Tabelle hms
.commission_order_hotel_info_ext
trx-id 107D2F81 lock_mode X warten
---TRANSAKTION 107D1795, ACTIVE 845 sec
5 lock-struct(s), heap-Größe 1248, 59 row lock(s), undo-log-Einträge 2
Der MySQL thread id 23819, OS-thread-handle 0x50dc7940, query-id 207389624 192.168.126.83 ppb
Trx-lese-Ansicht nicht sehen trx mit id >= 107D1796, sieht < 107D1796
TABLE LOCK table hms
.order_hotel_info
trx-id 107D1795 Sperrmodus IX
DATENSATZ SPERREN-space-id 2874 Seite 16 n bits 1272 index uniq_hotel_id
Tabelle hms
.order_hotel_info
trx-id 107D1795 lock_mode X-sperren rec aber keine Lücke
DATENSATZ SPERREN-space-id 2874 Seite 44 n bits 232 index PRIMARY
Tabelle hms
.order_hotel_info
trx-id 107D1795 lock_mode X-sperren rec aber keine Lücke
TABLE LOCK table hms
.commission_order_hotel_info_ext
trx-id 107D1795 Sperrmodus IX
DATENSATZ SPERREN-space-id 3123 Seite 3 n bit 128-index PRIMARY
Tabelle hms
.commission_order_hotel_info_ext
trx-id 107D1795 lock_mode X
welche Schritte es zu lösen
- Würden Sie bitte Ihre Transaktion Einstellungen und Ihren code damit wir sehen können, was könnte das Problem verursachen?
- nutzen Spring-annotation @Transactional,es zu werfen Ausnahme.aber ändern zu @Transactional(propagation=Propagation.REQUIRES_NEW) ,ist es ok.
- hinzufügen MySQL-server-Informationen.isolation ist REPEATABLE-READ
Du musst angemeldet sein, um einen Kommentar abzugeben.
Das Problem wird verursacht, durch die Verbindung nicht in der Lage zu bekommen eine Sperre auf die Zeile in der Datenbank. Dies wird verursacht, wenn eine andere Transaktion eine Sperre auf der gleichen Zeile so lange, dass Ihre Transaktion ein Timeout zu warten, für Sie zu vervollständigen und entsperren der Zeile ein. Es würde Hilfe für Sie, um Ihre Konfiguration, code-und Datenbank-server-Protokoll für die Zeit, damit wir feststellen können, wo das Problem herkommt; dies kann nicht ein problem verursacht durch den code, aber ein Problem mit einer anderen Anwendung nicht frei, es sperren, wie es sollte.
Ihren Kommentar, @Transactional(propagation=Propagation.REQUIRES_NEW) lässt sich der code funktionieren würde darauf hinweisen, dass eine Vorherige Transaktion, möglicherweise einer etablierten Methode-Kette ist nicht die Freigabe der Sperre, wie es sollte.
Wieder, fügen Sie Ihren code und Konfiguration. Ich sah Sie Ihre transactionManager bean-Deklaration von XML. Aber dieses mal, eigentlich gehören Ihr code und Ihre vollständige Datenquelle, und die Bohnen beteiligten in die Methode-chain-Konfiguration. Ich weiß, es kann scheinen, wie Sie arbeiten, um alle Ihre code, aber wenn Sie helfen wollen, müssen wir die info. Es kann nie zu viel Informationen in dieser situation. Wenn Sie möchten, ein Beispiel dafür, wie zu Fragen, ist eine gute Frage, bei mir Aussehen.