fix(registry): remove silent protocol filter in cacheInvoker (#3173)#3263
Closed
MoChengqian wants to merge 3 commits intoapache:mainfrom
Closed
fix(registry): remove silent protocol filter in cacheInvoker (#3173)#3263MoChengqian wants to merge 3 commits intoapache:mainfrom
MoChengqian wants to merge 3 commits intoapache:mainfrom
Conversation
…3173) Go consumer defaults to protocol "tri" while Java Dubbo 2.x providers register with protocol "dubbo". The protocol equality guard in cacheInvoker silently discarded mismatched providers, causing "No provider available". Remove the guard: registry-based discovery already scopes by interface/group/version, and MergeURL preserves the provider's protocol for correct downstream invocation. Add regression test Test_CrossProtocol_ProviderDiscovery_Issue3173.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3263 +/- ##
==========================================
- Coverage 48.15% 48.15% -0.01%
==========================================
Files 466 466
Lines 34048 34047 -1
==========================================
- Hits 16395 16394 -1
Misses 16322 16322
Partials 1331 1331 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



描述
#3173
移除 cacheInvoker 中的静默协议过滤
📝 BUG 描述
Go 消费端默认协议是 tri,Java Dubbo 2.x 服务端注册协议是 dubbo,cacheInvoker 里的逻辑需要provider和consumer协议匹配,然而版本更新后协议变化,原逻辑匹配内容变成需要判定 tri == dubbo ,守卫把协议不一致的provider 静默丢弃(未添加日志),导致消费端始终无法看到Java Dubbo 2.x 服务端使用dubbo协议的消费者 。
解决方案
删除 cacheInvoker 里按协议匹配过滤 provider 的条件判断,让所有注册中心发现的 provider 都进入缓存,由后续 MergeURL 保留各自协议完成正确调用
背景
当使用
client.NewClient创建 Go 消费者时,referenceUrl.Protocol默认值为"tri"(Triple 协议)。Java Dubbo 2.x 提供者在 ZooKeeper 中注册时使用protocol="dubbo"。cacheInvoker中原有的协议校验逻辑:if url.Protocol == referenceUrl.Protocol || referenceUrl.Protocol == "" {
对每一个 Java 提供者的评估结果均为 false,导致这些提供者被静默地从调用器缓存中移除。消费者始终看到"无可用提供者"的错误,且日志中没有任何错误或警告。
根本原因
在注册中心目录层进行协议过滤是多此一举的。ZooKeeper/Nacos 已经通过
接口 + 分组 + 版本号对提供者查找进行了范围限定。原有的协议校验是一个过早的预过滤,破坏了跨协议的互操作性。协议选择由下游处理:
MergeURL保留了提供者的协议字段,而ProtocolFilterWrapper.Refer使用该字段查找正确的处理器(例如DubboProtocol)。目录层不需要进行预过滤。变更内容
registry/directory/directory.go— 移除了cacheInvoker中的协议相等性校验;添加了引用此问题的解释性注释。registry/directory/directory_test.go— 新增回归测试Test_CrossProtocol_ProviderDiscovery_Issue3173:tri 消费者 + dubbo 提供者 → 提供者能被发现,且调用器保留protocol=dubbo。client/options.go— 精简了默认协议赋值处的注释,解释此 bug 的历史原因;移除了任何暗示跨协议缓存是稳定 API 契约的内容。检查清单
✅ 我确认目标分支是
develop✅ 代码已通过本地测试
✅ 我已添加证明修复有效的测试用例