codingapi / codingapi/tx-lcn

事务参与方发生异常,发起方不回滚

Offen
#360 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
4.2k
Forks
1.4k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- [x] I have searched the [issues](https://github.com/codingapi/tx-lcn/issues) of this repository and believe that this is not a duplicate.

### 1. Bug Description
两个服务在tm中均正常注册(每个单独的服务会在tm中有两个注册),在发起方异常时参与方会回滚,但是当参与方发生异常,发起方的事务不回滚

### 2. Environment:
- JDK version: 1.8
- OS: wimdows10
- TX-LCN version: 5.0.2
- Others:

### 3. Exception Stacktrace
事务发起方代码
@LcnTransaction(propagation = DTXPropagation.REQUIRED)
@Transactional(rollbackFor = Exception.class)
@Override
public int add(Demo demo) {
try {
//本服务保存
int i = demoSerivce.insertDemo(demo);
//远程服务保存
int add = feignServiceB.add(demo.getName());
return i;
} catch (Exception e) {
System.out.println("出现问题,抛出异常" + e);
throw new RuntimeException(e);
}
}
事务参与方
@LcnTransaction(propagation = DTXPropagation.REQUIRED)
@Transactional(rollbackFor = Exception.class)
@Override
public int add(Demo demo) {
try {
//本地保存
int i = demoSerivce.insertDemo(demo);
int ex = 10 / 0;
return i;
} catch (Exception e) {
System.out.println("出现问题,抛出异常" + e);
throw new RuntimeException(e);
}
}

发生异常的参与方日志
java.lang.ArithmeticException: / by zero
2019-04-26 12:22:57.805 ERROR 8232 --- [nio-9001-exec-1] c.c.txlcn.tc.core.DTXServiceExecutor : business code error @group(1b0b6c96e11537)

TM日志
2019-04-26 12:24:37.224 DEBUG 1788 --- [ntLoopGroup-5-1] c.c.t.txmsg.netty.handler.RpcCmdDecoder : cmd->{"key":"1b0b859a211536","msg":{"action":"createGroup","groupId":"1b0b859a211537","state":100},"remoteKey":"localhost/127.0.0.1:8070"}
2019-04-26 12:24:37.225 DEBUG 1788 --- [-rpc-service-12] com.codingapi.txlcn.txmsg.LCNCmdType : parsed txmsg cmd: createGroup
2019-04-26 12:24:37.357 DEBUG 1788 --- [-rpc-service-12] c.c.t.t.t.t.CreateGroupExecuteService : created group @group(1b0b859a211537)
2019-04-26 12:24:37.357 DEBUG 1788 --- [ntLoopGroup-5-1] c.c.t.txmsg.netty.handler.RpcCmdEncoder : send->{"key":"1b0b859a211536","msg":{"action":"createGroup","groupId":"1b0b859a211537","state":200},"remoteKey":"/127.0.0.1:8908"}
2019-04-26 12:24:37.753 DEBUG 1788 --- [ntLoopGroup-5-2] c.c.t.txmsg.netty.handler.RpcCmdDecoder : cmd->{"key":"1b0b85bb511537","msg":{"action":"notifyGroup","data":{"groupId":"1b0b859a211537","state":1},"groupId":"1b0b859a211537","state":100},"remoteKey":"/127.0.0.1:8070"}
2019-04-26 12:24:37.754 DEBUG 1788 --- [-rpc-service-13] com.codingapi.txlcn.txmsg.LCNCmdType : parsed txmsg cmd: notifyGroup
2019-04-26 12:24:37.801 DEBUG 1788 --- [-rpc-service-13] c.c.t.t.t.t.NotifyGroupExecuteService : notify group state: 1 @group(1b0b859a211537)
2019-04-26 12:24:37.822 DEBUG 1788 --- [-rpc-service-13] c.c.t.tm.core.SimpleTransactionManager : group[1b0b859a211537]'s transaction units: []
2019-04-26 12:24:37.822 DEBUG 1788 --- [-rpc-service-13] c.c.t.t.core.storage.redis.RedisStorage : remove group:1b0b859a211537 from redis.
2019-04-26 12:24:37.839 DEBUG 1788 --- [-rpc-service-13] c.c.t.t.t.t.NotifyGroupExecuteService : notify group successfully. @group(1b0b859a211537)
2019-04-26 12:24:37.839 DEBUG 1788 --- [ntLoopGroup-5-2] c.c.t.txmsg.netty.handler.RpcCmdEncoder : send->{"key":"1b0b85bb511537","msg":{"action":"notifyGroup","data":1,"groupId":"1b0b859a211537","state":200},"remoteKey":"/127.0.0.1:8938"}

### 4. Tour Idea

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start by tracing the participant failure from DTXServiceExecutor and compare it with the TM flow in NotifyGroupExecuteService and SimpleTransactionManager. Review the logged group state and RedisStorage removal to determine why the initiator is not rolled back. Done means a participant exception causes the originating service and participant transaction units to roll back consistently, with a regression test or reproducible verification.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, spring
Bereich
backend, distributed-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.