entrustBidMapper.deleteById("11111111");
EntrustBid entrustBid = new EntrustBid();
entrustBid.setId("11111111");
entrustBid.setEntrustId("11111111");
entrustBidMapper.insert(entrustBid);
entrustBidMapper.deleteById("22222222");
EntrustBid entrustBid2 = new EntrustBid();
entrustBid2.setId("22222222");
entrustBid2.setEntrustId("22222222");
List<EntrustBid> entrustList = new ArrayList<>();
entrustList.add(entrustBid2);
saveBatch(entrustList);
在全局事务中先删除一条数据,然后插入一条数据,两条数据的id保持一致,此时如果使用mybatisplus单条插入则没有问题,使用mybatisplus批量插入没有执行成功。
单条插入的时候由于id一致,第一次分支注册会失败,重试后改变了skipCheckLock字段就能注册成功,如下
2024-07-02 13:06:49.612 DEBUG 12996 --- [nio-8210-exec-2] i.s.c.r.n.AbstractNettyRemotingClient : offer message: BranchRegisterRequest{xid='172.16.7.244:8091:1612821884433429018', branchType=AT, resourceId='jdbc:mysql://172.16.1.212:8807/gov_finance', lockKey='entrust_bid:11111111', applicationData='{"skipCheckLock":true}'}
2024-07-02 13:06:49.612 DEBUG 12996 --- [Send_RMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : write message:SeataMergeMessage BranchRegisterRequest{xid='172.16.7.244:8091:1612821884433429018', branchType=AT, resourceId='jdbc:mysql://172.16.1.212:8807/gov_finance', lockKey='entrust_bid:11111111', applicationData='{"skipCheckLock":true}'}
, channel:[id: 0x1e94ac12, L:/172.16.6.39:61772 - R:/172.16.7.244:8091],active?true,writable?true,isopen?true
2024-07-02 13:06:49.623 DEBUG 12996 --- [ctor_RMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : io.seata.core.rpc.netty.RmNettyRemotingClient@30730ee7 msgId:8, body:MergeResultMessage BranchRegisterResponse{branchId=0, resultCode=Failed, msg='TransactionException[Global lock acquire failed xid = 172.16.7.244:8091:1612821884433429018 branchId = 1612821884433429023]'}
2024-07-02 13:06:49.863 DEBUG 12996 --- [nio-8210-exec-2] i.s.c.r.n.AbstractNettyRemotingClient : offer message: BranchRegisterRequest{xid='172.16.7.244:8091:1612821884433429018', branchType=AT, resourceId='jdbc:mysql://172.16.1.212:8807/gov_finance', lockKey='entrust_bid:11111111', applicationData='{"skipCheckLock":false}'}
2024-07-02 13:06:49.864 DEBUG 12996 --- [Send_RMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : write message:SeataMergeMessage BranchRegisterRequest{xid='172.16.7.244:8091:1612821884433429018', branchType=AT, resourceId='jdbc:mysql://172.16.1.212:8807/gov_finance', lockKey='entrust_bid:11111111', applicationData='{"skipCheckLock":false}'}
批量插入时只有第一次注册失败日志,并且插入操作没有执行成功,也没有任何错误信息
2024-07-02 15:29:39.966 DEBUG 22588 --- [nio-8210-exec-2] c.g.entrust.dao.EntrustBidMapper.insert : ==> Preparing: INSERT INTO entrust_bid ( id, entrust_id ) VALUES ( ?, ? )
2024-07-02 15:29:39.968 DEBUG 22588 --- [nio-8210-exec-2] c.g.entrust.dao.EntrustBidMapper.insert : ==> Parameters: 22222222(String), 22222222(String)
2024-07-02 15:29:39.980 DEBUG 22588 --- [nio-8210-exec-2] i.s.c.r.n.AbstractNettyRemotingClient : offer message: xid=172.16.7.244:8091:1612821884433430391,branchType=AT,resourceId=jdbc:mysql://172.16.1.212:8807/gov_finance,lockKey=entrust_bid:22222222
2024-07-02 15:29:39.981 DEBUG 22588 --- [Send_RMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : write message:SeataMergeMessage xid=172.16.7.244:8091:1612821884433430391,branchType=AT,resourceId=jdbc:mysql://172.16.1.212:8807/gov_finance,lockKey=entrust_bid:22222222
, channel:[id: 0x1fa49591, L:/172.16.6.39:51115 - R:/172.16.7.244:8091],active?true,writable?true,isopen?true
2024-07-02 15:29:39.987 DEBUG 22588 --- [ctor_RMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : io.seata.core.rpc.netty.RmNettyRemotingClient@67e03559 msgId:13, body:MergeResultMessage BranchRegisterResponse: branchId=0,result code =Failed,getMsg =TransactionException[Global lock acquire failed xid = 172.16.7.244:8091:1612821884433430391 branchId = 1612821884433430402]
2024-07-02 15:29:40.064 DEBUG 22588 --- [ctor_TMROLE_1_1] i.s.c.rpc.netty.AbstractNettyRemoting : io.seata.core.rpc.netty.TmNettyRemotingClient@d420520 msgId:5, body:globalStatus=Committed,ResultCode=Success,Msg=null
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。