Skip to content
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: in dubbo 3.x version, the consumer can't generate tcc proxy. #6101

Merged
merged 27 commits into from
Dec 18, 2023

Conversation

laywin
Copy link
Contributor

@laywin laywin commented Dec 3, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

#6099

Ⅱ. Does this pull request fix one issue?

fixes #6099
fixes #6096

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

laywin and others added 20 commits November 14, 2023 16:23
# Conflicts:
#	changes/en-us/2.0.0.md
#	changes/zh-cn/2.0.0.md
#	rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java
#	rm-datasource/src/test/java/io/seata/rm/RMHandlerATTest.java
…atic mock

2. throw exception when the db type not support in AT mode
3. add author register info
# Conflicts:
#	changes/zh-cn/2.x.md
2. remove tryOtherApp when get channel, so it can default use other same resourceId channel but difference app when the is no channel in same app.
� Conflicts:
�	changes/en-us/2.x.md
�	changes/zh-cn/2.x.md
Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Merging #6101 (a6af930) into 2.x (501d431) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6101      +/-   ##
============================================
- Coverage     48.98%   48.95%   -0.04%     
+ Complexity     4782     4773       -9     
============================================
  Files           913      913              
  Lines         31697    31697              
  Branches       3823     3823              
============================================
- Hits          15528    15518      -10     
- Misses        14632    14644      +12     
+ Partials       1537     1535       -2     
Files Coverage Δ
...n/java/io/seata/core/rpc/netty/ChannelManager.java 0.00% <ø> (ø)
...va/io/seata/integration/tx/api/util/DubboUtil.java 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

@@ -34,6 +34,8 @@ private DubboUtil() {
private static final String ALIBABA_DUBBO_PROXY_NAME_PREFIX = "com.alibaba.dubbo.common.bytecode.proxy";
private static final String APACHE_DUBBO_PROXY_NAME_PREFIX = "org.apache.dubbo.common.bytecode.proxy";

private static final String DUBBO_3_X_PARTIAL_PROXY_NAME = "DubboProxy";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you only use contains? and not startsWith or endsWith?
只能使用contains?而不是startsWith或者endsWith吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

there is no fixed prefix or suffix in generated proxy name, i will try later to concat a prefix to judge.
生成代理名字的时候没有固定的前缀和后缀,我看能不能凭借一个前缀来判断.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deeply analyzing the source code is really excellent.

@@ -399,7 +400,7 @@ public static Channel getChannel(String resourceId, String clientId, boolean try
}
}

if (resultChannel == null && tryOtherApp) {
if (resultChannel == null && BranchType.TCC == branchType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要改变入参,而不是在由调用方决定是否开启tryOtherApp
Why change the entry parameter when it's up to the caller to turn on tryOtherApp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel the place convention over configuration is better, method signature is better understood without loss of flexibility.
这个地方感觉用 预定大于配置 的方法更好一点,不失灵活性的同时方法签名也更好理解.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel the place convention over configuration is better, method signature is better understood without loss of flexibility. 这个地方感觉用 预定大于配置 的方法更好一点,不失灵活性的同时方法签名也更好理解.

I'm not sure if there are any other branch types that need this in the future, but if they all rely on an internal if || it's just too low.
未来不确定有没有其他的分支类型需要这种,如果都靠内部一个if || 这种写法太low了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tryOtherApp in AT transaction mode? The original logic is that only AT mode can go here, now only TCC mode can go here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tryOtherApp in AT transaction mode? The original logic is that only AT mode can go here, now only TCC mode can go here?

yeah, because of TCC rpc mode regiter branch in constomer, send order of TC two stage to provider. so it can't find the channel as normal, so tcc model will try other app. @funky-eyes 's opinion there may be a risk in at to find a same resource diff app channel, ex: two instance have status.

是的,因为TCC RPC模式是在消费者端注册分支,TC在二阶段下发指令给服务者端。导致通过消费者端的app去找服务者端的channel的时候会失败,所以tcc 模式会尝试其他app channel. @funky-eyes 的建议在AT模式下发指令到相同资源不同app的端可能存在风险, 比如两台实例可能有状态的情况下.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel the place convention over configuration is better, method signature is better understood without loss of flexibility. 这个地方感觉用 预定大于配置 的方法更好一点,不失灵活性的同时方法签名也更好理解.

I'm not sure if there are any other branch types that need this in the future, but if they all rely on an internal if || it's just too low. 未来不确定有没有其他的分支类型需要这种,如果都靠内部一个if || 这种写法太low了

no problem, i will rollback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tryOtherApp in AT transaction mode? The original logic is that only AT mode can go here, now only TCC mode can go here?

yeah, because of TCC rpc mode regiter branch in constomer, send order of TC two stage to provider. so it can't find the channel as normal, so tcc model will try other app. @funky-eyes 's opinion there may be a risk in at to find a same resource diff app channel, ex: two instance have status.

是的,因为TCC RPC模式是在消费者端注册分支,TC在二阶段下发指令给服务者端。导致通过消费者端的app去找服务者端的channel的时候会失败,所以tcc 模式会尝试其他app channel. @funky-eyes 的建议在AT模式下发指令到相同资源不同app的端可能存在风险, 比如两台实例可能有状态的情况下.

Maybe this is not the scope of this bugfix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tryOtherApp in AT transaction mode? The original logic is that only AT mode can go here, now only TCC mode can go here?

yeah, because of TCC rpc mode regiter branch in constomer, send order of TC two stage to provider. so it can't find the channel as normal, so tcc model will try other app. @funky-eyes 's opinion there may be a risk in at to find a same resource diff app channel, ex: two instance have status.
是的,因为TCC RPC模式是在消费者端注册分支,TC在二阶段下发指令给服务者端。导致通过消费者端的app去找服务者端的channel的时候会失败,所以tcc 模式会尝试其他app channel. @funky-eyes 的建议在AT模式下发指令到相同资源不同app的端可能存在风险, 比如两台实例可能有状态的情况下.

Maybe this is not the scope of this bugfix.

tcc rpc mode can't find the channel, if no this change.

@funky-eyes funky-eyes added this to the 2.1.0 milestone Dec 4, 2023
@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. module/spring spring module module/server server module module/core core module module/intergration-tx-api intergration-tx-api and removed module/spring spring module labels Dec 4, 2023
@@ -192,7 +192,7 @@ protected BranchStatus branchCommitSend(BranchCommitRequest request, GlobalSessi
BranchSession branchSession) throws IOException, TimeoutException {

BranchCommitResponse response = (BranchCommitResponse) remotingServer.sendSyncRequest(
branchSession.getResourceId(), branchSession.getClientId(), request, branchSession.isAT());
branchSession.getResourceId(), branchSession.getClientId(), request, branchSession.getBranchType() == BranchType.TCC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this change?

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot agree with this plan. Consider what would happen if there were no multi-tenancy isolation in TCC.

@funky-eyes
Copy link
Contributor

I cannot agree with this plan. Consider what would happen if there were no multi-tenancy isolation in TCC.

A long time ago, the version is to allow tcc to be sent to other apps, and in the consumer side of the first stage of registration, the second stage in the provider side of the submission rely on this function, this pr just restore the previous practice
很久以前的版本就是允许tcc下发的其他的app中,而且在consumer侧一阶段注册,二阶段在provider侧提交靠的就是这个功能,这个pr只是还原了以前的做法

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@funky-eyes funky-eyes merged commit 2f9957b into apache:2.x Dec 18, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/core core module module/intergration-tx-api intergration-tx-api module/server server module type: bug Category issues or prs related to bug.
Projects
None yet
4 participants