-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: fix not return value when branchCommit and branchRollback throw exception #2755
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2755 +/- ##
=============================================
+ Coverage 50.35% 50.49% +0.13%
Complexity 2919 2919
=============================================
Files 572 572
Lines 18612 18613 +1
Branches 2212 2242 +30
=============================================
+ Hits 9373 9398 +25
+ Misses 8286 8285 -1
+ Partials 953 930 -23 |
@@ -52,7 +52,7 @@ | |||
out.writeShort((short)0); | |||
} | |||
out.writeLong(branchId); | |||
out.writeByte(branchStatus.getCode()); | |||
out.writeByte((branchStatus == null ? BranchStatus.Unknown : branchStatus).getCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main problem is that what kind of situation would let the branch status null in branch commit or branch rollback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because when branch commit or rollback, the branch status should not be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll find out why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main problem is that what kind of situation would let the branch status null in branch commit or branch rollback.
I found the cause of the problem and fixed it.
does it break consistency without retrying? |
嗯,我也考虑过。但是重试的频率太快了,如果同时有很多个事务都这样在重试,日志都要爆了。 |
我觉得你可以换个思路,给重试加上上限值,这个上限值可以通过配置中心获取.超过上限值后日志输出一次需要人工介入处理的日志. |
嗯,不断重试的原因肯定是由系统来找原因。只是我觉得seata最好也能提供一个重试的规则配置。 |
我觉得你可以把这个pr转化为这个方向,加入一个重试的规则配置.原因的话seata一般有打印,比如脏读写的镜像数据与当前匹配不上. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rollback fail retrying we should talk it in issue. Let us solve the problem that make the branch status null first. I already check the logic in
io.seata.rm.datasource.DataSourceManager#branchRollback
io.seata.rm.datasource.DataSourceManager#branchCommit
But look like the branch status would not be null.
Can you check these classes make the branch status null?
SagaResourceManager
TCCResourceManager
ResourceManagerXA
DataSourceManager
RM和分支事务的状态并没有问题,而是出现异常时没有将状态写入BranchRollbackResponse中,从而导致AbstractBranchEndResponseCodec输出响应时,抛了空指针异常。 |
2)TCC的RM的二阶段不再往外抛异常,而是直接“return BranchStatus.PhaseTwo_XxxxxxFailed_Retryable;”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
现在换了一种处理方式,不是由AbsRMHandler去补response的数据,而是由各RM拦截异常并返回相应的BranchStatus,来避免因异常导致response数据未写入。
…------------------ 原始邮件 ------------------
发件人: "FUNKYE"<notifications@github.com>;
发送时间: 2020年6月5日(星期五) 下午5:08
收件人: "seata/seata"<seata@noreply.github.com>;
抄送: "王良"<841369634@qq.com>;"State change"<state_change@noreply.github.com>;
主题: Re: [seata/seata] bugfix: Response data not written when commit or rollback failed in tcc resource manager. (#2755)
@a364176773 approved this pull request.
LGTM
In rm/src/main/java/io/seata/rm/AbstractRMHandler.java:
> response.setXid(xid); response.setBranchId(branchId); - response.setBranchStatus(status); - if (LOGGER.isInfoEnabled()) { - LOGGER.info("Branch commit result: " + status); + try {
这块代码改动的目的是?原来是直接拿到status放入即可.doBranchCommit ,doBranchRollback都一样
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
bugfix: TCC分支事务,在commit或rollback出现异常时,response不会写入分支事务数据的BUG修复。
此BUG会造成输出响应时抛出空指针异常。代码行:
io.seata.serializer.seata.protocol.transaction.AbstractBranchEndResponseCodec中的
55行 out.writeByte(branchStatus.getCode());
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
目前还遗留了一直异常时不断且快速重试的问题。需要新的重试机制的PR来解决此问题。