-
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
optimize: distinguish database behavior according to the branch type #2415
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2415 +/- ##
==========================================
Coverage 51.20% 51.20%
Complexity 2811 2811
==========================================
Files 554 554
Lines 17774 17774
Branches 2100 2100
==========================================
Hits 9102 9102
Misses 7812 7812
Partials 860 860 |
...c/main/java/io/seata/integration/dubbo/alibaba/AlibabaDubboTransactionPropagationFilter.java
Outdated
Show resolved
Hide resolved
.../dubbo/src/main/java/io/seata/integration/dubbo/ApacheDubboTransactionPropagationFilter.java
Outdated
Show resolved
Hide resolved
.../dubbo/src/main/java/io/seata/integration/dubbo/ApacheDubboTransactionPropagationFilter.java
Outdated
Show resolved
Hide resolved
@@ -66,7 +68,7 @@ | |||
StatementCallback<T, S> statementCallback, | |||
Object... args) throws SQLException { | |||
|
|||
if (!RootContext.inGlobalTransaction() && !RootContext.requireGlobalLock()) { | |||
if (!requiresUndoFunction()) { |
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.
@GlobalLock does not have undo, this function name should be optimized
} else { | ||
if (rpcXid != null) { | ||
RootContext.bind(rpcXid); | ||
RootContext.bindInterceptorType(rpcXidInterceptorType); | ||
if (StringUtils.equals(BranchType.TCC.name(), rpcBranchType)) { | ||
RootContext.bindBranchType(BranchType.TCC); |
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.
Saga branch never set ?
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 have discussed with the author of saga. This pr is only responsible for the branchType judgment logic in ExecuteTemplate and the TCC branchType passing in Filter. The specific Saga branchtype assignment and other logic will be provided by the feature saga related pr
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.
this #2551, autor is wangliang1986
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
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
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug("xid in RootContext[{}] xid in RpcContext[{}]", xid, rpcXid); | ||
} | ||
boolean bind = false; | ||
if (xid != null) { | ||
RpcContext.getContext().setAttachment(RootContext.KEY_XID, xid); | ||
RpcContext.getContext().setAttachment(RootContext.KEY_XID_INTERCEPTOR_TYPE, xidInterceptorType); | ||
RpcContext.getContext().setAttachment(RootContext.KEY_BRANCH_TYPE, branchType); |
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.
Is it better to separate and judge?
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.
It will not be processed this time, and transaction context object encapsulation will be provided later to handle log output uniformly.
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug("unbind[{}] interceptorType[{}] from RootContext", unbindXid, unbindInterceptorType); | ||
LOGGER.debug("unbind xid [{}] branchType [{}] from RootContext", unbindXid, previousBranchType); |
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.
BranchType print null in AT mode is not very elegant.
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.
How about judge in the log output temporarily,and print "AT" if it is null
@@ -115,4 +117,17 @@ | |||
} | |||
return rs; | |||
} | |||
|
|||
private static boolean requiresLockOrUndoFunction() { |
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.
Other more meaningful method name?
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.
Change it to "shouldExecuteInATMode"
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
此PR合并后,出现的BUG: 在TCC或SAGA事务内,还执行了SQL识别功能,导致SAGA事务执行失败。 中的RootContext.inGlobalTransaction()是否应该改为ExecuteTemplate.shouldExecuteInATMode()。 |
抱歉给您带来了问题,是的,确实有这个问题,虽然执行的时候不进行sql解析构建undoLog了,但是这里还是会执行sql识别,这是我的疏忽,我马上提交一个修复pr |
OK |
|
Ⅰ. Describe what this PR did
1.Change the interceptorType to branchType,optimize the logic in TccActionInterceptor
2.Optimize the judge condition of use UndoFunction in AT's ExecuteTemplate
Ⅱ. 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