codingapi / codingapi/tx-lcn

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

オープン
#360 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
4.2k
フォーク
1.4k
PR マージ指標
30日以内にマージされた PR はありません

説明

- [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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、DTXServiceExecutorから参加者の失敗を追跡し、NotifyGroupExecuteServiceおよびSimpleTransactionManagerのTMフローと比較します。ログに記録されたグループ状態とRedisStorageからの削除を確認し、イニシエーターがロールバックされない理由を特定します。参加者の例外によって、発生元サービスと参加者のトランザクション単位が一貫してロールバックされ、回帰テストまたは再現可能な検証があることを完了条件とします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, spring
領域
backend, distributed-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。