apache / apache/incubator-seata
TransactionSystemException: Could not commit JDBC transaction; nested exception is io.seata.rm.datasource.exec.LockConflictException
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
- [x] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.
### Ⅰ. Issue Description
seata 0.5.1 版本。
出现异常: Could not commit JDBC transaction; nested exception is io.seata.rm.datasource.exec.LockConflictException
sql 语句涉及四张表:
有三个表update
一个表 Insert
### Ⅱ. Describe what happened
```
2019-05-09 10:36:15.478 DEBUG io.seata.core.context.RootContext Line:57 - bind 172.26.177.17:8901:2011125712
Preparing: UPDATE shar_rental_demand SET grab_status=?,grab_id=?,grab_tenant_id=? WHERE is_delete=0 AND id = ? AND grab_status = ?
Parameters: 2(Integer), c0fe227c79f94afd5f7259c2ce935e80(String), 02700001(String), ca64e443dc3f45f6d852ec98a1b96795(String), 1(Integer)
<== Updates: 1
Preparing: update shar_score_balance bal set bal.available_balance = bal.available_balance - ?, bal.total_revenue = bal.total_revenue - ?, bal.grab_count = bal.grab_count + 1, bal.update_time=now() where bal.emp_id = ?
Parameters: 10(Integer), 10(Integer), c0fe227c79f94afd5f7259c2ce935e80(String)
<== Updates: 1
Preparing: INSERT INTO shar_score_record ( id, score, direction, description, biz_type, biz_id, emp_id, create_time, update_time, is_delete ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
Parameters: 9dbfd33e169ff9526212d57ef68ebac1(String), 10(Integer), 2(Integer), 抢单: Seata9[](String), 2(Integer), ca64e443dc3f45f6d852ec98a1b96795(String), c0fe227c79f94afd5f7259c2ce935e80(String), 2019-05-09 10:36:15.557(Timestamp), 2019-05-09 10:36:15.557(Timestamp), 0(Integer)
<== Updates: 1
Preparing: UPDATE shar_rental_demand_record SET grab_tenant_id=?,grab_id=? WHERE is_delete=0 AND id = ?
Parameters: 02700001(String), c0fe227c79f94afd5f7259c2ce935e80(String), ca64e443dc3f45f6d852ec98a1b96795(String)
<== Updates: 1
2019-05-09 10:36:15.579 DEBUG io.seata.core.rpc.netty.AbstractRpcRemoting Line:239 - offer message: xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
2019-05-09 10:36:15.580 DEBUG io.seata.core.rpc.netty.AbstractRpcRemoting Line:297 - write message:SeataMergeMessage xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
, channel:[id: 0x1a909cda, L:/172.22.0.24:58218 - R:/172.26.177.17:8901],active?true,writable?true,isopen?true
2019-05-09 10:36:15.580 DEBUG io.seata.core.rpc.netty.MessageCodecHandler Line:116 - Send:SeataMergeMessage xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
2019-05-09 10:36:15.584 DEBUG io.seata.core.rpc.netty.MessageCodecHandler Line:206 - Receive:MergeResultMessage BranchRegisterResponse: branchId=0,result code =Failed,getMsg =TransactionException[null]
,messageId:636
2019-05-09 10:36:15.586 DEBUG io.seata.core.rpc.netty.AbstractRpcRemoting Line:297 - write message:SeataMergeMessage xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
, channel:[id: 0x1a909cda, L:/172.22.0.24:58218 - R:/172.26.177.17:8901],active?true,writable?true,isopen?true
2019-05-09 10:36:15.586 DEBUG io.seata.core.rpc.netty.AbstractRpcRemoting Line:239 - offer message: xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
2019-05-09 10:36:15.587 DEBUG io.seata.core.rpc.netty.MessageCodecHandler Line:116 - Send:SeataMergeMessage xid=172.26.177.17:8901:2011125712,branchType=AT,resourceId=jdbc:mysql://172.17.0.1:3306/ltfox_sharedpool?allowMultiQueries=true&serverTimezone=PRC&useUnicode=true&characterEncoding=UTF-8&useSSL=false,lockKey=shar_rental_demand:ca64e443dc3f45f6d852ec98a1b96795;shar_score_balance:1110897170782883841;shar_score_record:9dbfd33e169ff9526212d57ef68ebac1;shar_rental_demand_record:ca64e443dc3f45f6d852ec98a1b96795
2019-05-09 10:36:15.588 DEBUG io.seata.core.rpc.netty.MessageCodecHandler Line:206 - Receive:MergeResultMessage BranchRegisterResponse: branchId=0,result code =Failed,getMsg =TransactionException[null]
,messageId:638
org.springframework.transaction.TransactionSystemException: Could not commit JDBC transaction; nested exception is io.seata.rm.datasource.exec.LockConflictException
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:332)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:746)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:714)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:533)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:304)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at xxx.modules.sharedpool.demand.service.impl.RentalDemandServiceImpl$$EnhancerBySpringCGLIB$$f2b7fd67.grabDemand()
at xxx.modules.sharedpool.demand.controller.RentalDemandController.grab(RentalDemandController.java:97)
Caused by: io.seata.rm.datasource.exec.LockConflictException: null
at io.seata.rm.datasource.ConnectionProxy.recognizeLockKeyConflictException(ConnectionProxy.java:131)
at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:182)
at io.seata.rm.datasource.ConnectionProxy.commit(ConnectionProxy.java:159)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:329)
... 126 common frames omitted
2019-05-09 10:36:15.597 DEBUG io.seata.core.context.RootContext Line:83 - unbind 172.26.177.17:8901:2011125712
2019-05-09 10:36:17.621 DEBUG io.seata.core.rpc.netty.TmRpcClient Line:207 - will send ping msg,channel[id: 0x182b4850, L:/172.22.0.24:58216 - R:/172.26.177.17:8901]
2019-05-09 10:36:17.622 DEBUG io.seata.core.rpc.netty.AbstractRpcRemoting Line:297 - write message:services ping, channel:[id: 0x182b4850, L:/172.22.0.24:58216 - R:/172.26.177.17:8901],active?true,writable?true,isopen?true
2019-05-09 10:36:17.622 DEBUG io.seata.core.rpc.netty.AbstractRpcRemotingClient Line:272 - received PONG from /172.26.177.17:8901
```
### Ⅳ. How to reproduce it (as minimally and precisely as possible)
业务描述:
有 A、B、C 三个服务,A无DB连接。Seata-Server 一同注册到 Eureka。
1. A先调用B,再调用C
2. B 和 C 有一张相同结构的表
3. 需要将 B 服务的一行数据copy到 C服务
### Ⅵ. Environment:
- JDK version : 11
- OS : Linux 7.4
- Others: spring cloud + seata + eureka + feign + hystrix
Contributor guide
Research direction
Start with io.seata.rm.datasource.ConnectionProxy and the DataSourceTransactionManager stack frames, then reproduce the A/B/C service flow with the shared table and four SQL operations described in the issue. Done means the LockConflictException in Seata 0.5.1 is explained and a verified resolution or limitation is documented for this environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100