codingapi / codingapi/tx-lcn

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

Đang mở
#360 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
4.2k
Fork
1.4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng cách truy vết lỗi của participant từ DTXServiceExecutor và so sánh với luồng TM trong NotifyGroupExecuteService và SimpleTransactionManager. Kiểm tra trạng thái group được ghi log và việc xóa khỏi RedisStorage để xác định tại sao initiator không được rollback. Hoàn tất có nghĩa là một exception của participant khiến service khởi tạo và các transaction unit của participant được rollback nhất quán, kèm theo một regression test hoặc verification có thể tái hiện.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, spring
Lĩnh vực
backend, distributed-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.