Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
bugfix: grpc interceptor xid unbinding problem (apache#5577)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenFaust authored May 16, 2023
1 parent 0b49e06 commit d1e6e6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The version is updated as follows:
- [[#5523](https://github.com/seata/seata/pull/5523)] fix GlobalStatus=9 can't be cleared in DB storage mode
- [[#5558](https://github.com/seata/seata/pull/5558)] fix mariadb rollback failed
- [[#5556](https://github.com/seata/seata/pull/5556)] fix oracle insert undolog failed
- [[#5577](https://github.com/seata/seata/pull/5577)] fix grpc interceptor xid unbinding problem

### optimize:
- [[#5208](https://github.com/seata/seata/pull/5208)] optimize throwable getCause once more
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5523](https://github.com/seata/seata/pull/5523)] 修复 GlobalStatus=9 在DB存储模式无法清除的问题
- [[#5558](https://github.com/seata/seata/pull/5558)] 修复mariadb回滚失败的问题
- [[#5556](https://github.com/seata/seata/pull/5556)] 修复 oracle 插入 undolog 失败问题
- [[#5577](https://github.com/seata/seata/pull/5577)] 修复 grpc拦截器解绑xid失败问题

### optimize:
- [[#5208](https://github.com/seata/seata/pull/5208)] 优化多次重复获取Throwable#getCause问题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void onMessage(ReqT message) {

@Override
public void onHalfClose() {
cleanContext();
if (StringUtils.isNotBlank(xid)) {
RootContext.bind(xid);
String branchType = context.get(RootContext.KEY_BRANCH_TYPE);
Expand All @@ -63,13 +64,11 @@ public void onHalfClose() {

@Override
public void onCancel() {
cleanContext();
target.onCancel();
}

@Override
public void onComplete() {
cleanContext();
target.onComplete();
}

Expand All @@ -79,20 +78,10 @@ public void onReady() {
}

private void cleanContext() {
if (StringUtils.isNotBlank(xid) && RootContext.inGlobalTransaction()) {
String unbindXid = RootContext.unbind();
BranchType previousBranchType = RootContext.getBranchType();
if (BranchType.TCC == previousBranchType) {
RootContext.unbindBranchType();
}
if (!xid.equalsIgnoreCase(unbindXid)) {
RootContext.bind(unbindXid);
LOGGER.warn("bind xid [{}] back to RootContext", unbindXid);
if (BranchType.TCC == previousBranchType) {
RootContext.bindBranchType(previousBranchType);
LOGGER.warn("bind branchType [{}] back to RootContext", previousBranchType);
}
}
RootContext.unbind();
BranchType previousBranchType = RootContext.getBranchType();
if (BranchType.TCC == previousBranchType) {
RootContext.unbindBranchType();
}
}
}

0 comments on commit d1e6e6b

Please sign in to comment.