apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.34k stars 8.79k forks source link

Transaction not rollback? #1570

Closed queal closed 5 years ago

queal commented 5 years ago

seata 0.8

Ⅰ. Issue Description

node1 --(fegin)> node2,

node1 throw Exception, node2 not rollback

Ⅱ. Describe what happened

node1: image

node2: image

invoke track : addGoods1(node1) - fegin -> addGoods(node2)

when addGoods1 throw Exception, Goods.id N1 rollback, but node2 goods.N2 exists

image

seata log : image

Ⅲ. Describe what you expected to happen

does node2 shoud rollback ? or any config is wrong?

transaction.undo.data.validation = true in nacos image

Ⅴ. Anything else we need to know?

i just learn seata, and springcloud alibaba, i want to know where has the problem?

thanks for all, i wish seata more better`

but node1 -> node2(here throw Exceptioin) , global transaction works`

Ⅵ. Environment:

xingfudeshi commented 5 years ago

Show me logs of client side.

queal commented 5 years ago

node1 log:

2019-09-02 11:51:33.011  INFO 932 --- [o-18081-exec-10] i.seata.tm.api.DefaultGlobalTransaction  : Begin new global transaction [192.168.11.180:8091:2021119793]
2019-09-02 11:51:33.644  INFO 932 --- [o-18081-exec-10] i.seata.tm.api.DefaultGlobalTransaction  : [192.168.11.180:8091:2021119793] rollback status:Rollbacked
2019-09-02 11:51:33.646 ERROR 932 --- [o-18081-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NumberFormatException: For input string: "s"] with root cause

java.lang.NumberFormatException: For input string: "s"

node2 log:

2019-09-02 11:51:33.189  INFO 16000 --- [io-18082-exec-4] i.seata.tm.api.DefaultGlobalTransaction  : Begin new global transaction [192.168.11.180:8091:2021119797]
2019-09-02 11:51:33.456  INFO 16000 --- [io-18082-exec-4] i.seata.tm.api.DefaultGlobalTransaction  : [192.168.11.180:8091:2021119797] commit status:Committed
2019-09-02 11:51:33.508  INFO 16000 --- [atch_RMROLE_5_8] i.s.core.rpc.netty.RmMessageListener     : onMessage:xid=192.168.11.180:8091:2021119793,branchId=2021119795,branchType=AT,resourceId=jdbc:mysql://192.168.11.105:3306/seata-test,applicationData=null
2019-09-02 11:51:33.508  INFO 16000 --- [atch_RMROLE_5_8] io.seata.rm.AbstractRMHandler            : Branch Rollbacking: 192.168.11.180:8091:2021119793 2021119795 jdbc:mysql://192.168.11.105:3306/seata-test
2019-09-02 11:51:33.544  INFO 16000 --- [atch_RMROLE_5_8] i.s.rm.datasource.undo.UndoLogManager    : xid 192.168.11.180:8091:2021119793 branch 2021119795, undo_log deleted with GlobalFinished
2019-09-02 11:51:33.549  INFO 16000 --- [atch_RMROLE_5_8] io.seata.rm.AbstractRMHandler            : Branch Rollbacked result: PhaseTwo_Rollbacked
2019-09-02 11:51:33.685  INFO 16000 --- [atch_RMROLE_6_8] i.s.core.rpc.netty.RmMessageListener     : onMessage:xid=192.168.11.180:8091:2021119797,branchId=2021119799,branchType=AT,resourceId=jdbc:mysql://192.168.11.105:3306/seata-test,applicationData=null
2019-09-02 11:51:33.685  INFO 16000 --- [atch_RMROLE_6_8] io.seata.rm.AbstractRMHandler            : Branch committing: 192.168.11.180:8091:2021119797 2021119799 jdbc:mysql://192.168.11.105:3306/seata-test null
2019-09-02 11:51:33.685  INFO 16000 --- [atch_RMROLE_6_8] io.seata.rm.AbstractRMHandler            : Branch commit result: PhaseTwo_Committed

seata log:

2019-09-02 11:51:32.955 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage timeout=60000,transactionName=addGoods1()
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.030 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119793,branchType=AT,resourceId=jdbc:mysql://192.168.11.105:3306/seata-test,lockKey=seata_goods:N1RSoGSM8aKNFLgZPEUCObGa1eqippGi
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.120 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119793,branchId=2021119795,resourceId=null,status=PhaseOne_Done,applicationData=null
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.167 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage timeout=60000,transactionName=addGoods()
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.232 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119797,branchType=AT,resourceId=jdbc:mysql://192.168.11.105:3306/seata-test,lockKey=seata_goods:N2tr8SauSgfVp6RZcgS7XpsyzaOSlcDe
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.312 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119797,branchId=2021119799,resourceId=null,status=PhaseOne_Done,applicationData=null
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.358 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119797,extraData=null
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.470 INFO [batchLoggerPrint_1]io.seata.core.rpc.DefaultServerMessageListenerImpl.run:199 -SeataMergeMessage xid=192.168.11.180:8091:2021119793,extraData=null
,clientIp:192.168.11.180,vgroup:my_test_tx_group

2019-09-02 11:51:33.506 INFO [ServerHandlerThread_82_500]io.seata.core.rpc.ChannelManager.getChannel:441 -Choose [id: 0x860634c2, L:/192.168.11.180:8091 - R:/192.168.11.180:53574] on the same resource[jdbc:mysql://192.168.11.105:3306/seata-test]  as alternative of seata-node1:192.168.11.180:62567
2019-09-02 11:51:33.599 INFO [ServerHandlerThread_82_500]io.seata.server.coordinator.DefaultCore.doGlobalRollback:309 -Successfully rollbacked branch BR:2021119795/2021119793
2019-09-02 11:51:33.766 INFO [AsyncCommitting_1]io.seata.server.coordinator.DefaultCore.doGlobalCommit:238 -Global[192.168.11.180:8091:2021119797] committing is successfully done.

except result db has N2 record: image

slievrly commented 5 years ago

@queal please print the xid of node1 and node2 ,compare these if equals.

queal commented 5 years ago

@queal please print the xid of node1 and node2 ,compare these if equals.

i list the log, xid not equals, how should i maunal set that?

i followed this wiki https://github.com/seata/seata-samples/blob/master/doc/quick-integration-with-spring-cloud.md

slievrly commented 5 years ago

@queal does pom.xml has spring-cloud-alibaba-seata dependency?

slievrly commented 5 years ago

There are 3 samples about springcloud in https://github.com/seata/seata-samples .

queal commented 5 years ago

There are 3 samples about springcloud in https://github.com/seata/seata-samples .

thx, i forgot the spring-cloud-alibaba-seata dependency, then RootContext.getXid() equals, it works~

someone may found this : no available server to connect search this key [spring.cloud.alibaba.seata.tx-service-group] -> https://github.com/seata/seata-samples/blob/master/doc/quick-integration-with-spring-cloud.md