dubbo
dubbo copied to clipboard
Zookeeper need catch exception when write failed
假设 zk 上的 dubbo 注册信息根路径是 /dubbo. 上面有接口级的例如
/dubbo/com.example.SomeInterface
还有应用级的, 例如
/dubbo/SomeService
- 127.0.0.1:20880
当 org.apache.dubbo.registry.zookeeper.ZookeeperRegistry#doSubscribe 调用的时候, 如果走到了 ANY_VALUE.equals(url.getServiceInterface()) 的分支, 会把底下所有子节点都 subscribe.
即上面例子的 /dubbo/com.example.SomeInterface 和 /dubbo/SomeService 都 subscribe 了. 这两个子节点会触发
for (String path : toCategoriesPath(url)) {
...
zkClient.create(path, false);
...
}
于是应用级的接口就会变成这样
/dubbo/SomeService
- 127.0.0.1:20880
- configurators
- consumers
- providers
- routers
应用级节点里面的每个子节点(例子中的127.0.0.1:20880)的内容应该是可以序列化到 ServiceInstance 的 json. 但是 configurators, consumers, providers, routers 这几个自动创建的不是 json. 导致解析错误
应用级的注册根路径为 /services
应用级的注册根路径为 /services
什么意思, 是用户使用的时候保证应用级注册到 /services 吗? 还是说 dubbo 在写应用级节点的时候自己处理的
我认为不管根目录是什么都会触发这个 bug.
我注册时指定了 group, 所以会用 group 作为根目录. dubbo admin 启动的时候会去根目录的每个子节点写 configurators, consumers, providers, routers.
把根目录从 group 变成默认的 /services 也是一样的
- 接口级和应用级的写入路径都已经跑了很多年了,所以修改写入的格式目前来看不太现实
- 这个问题仅在配置了注册中心的 group 以后会发生
- ANY_VALUE 这个写入进发生在 dubbo-admin 中,正常的请求逻辑不会有这种订阅
综上,最好的解决方案是 dubbo-admin 侧在订阅的时候修改实现的模式
或者考虑在解析节点的时候 catch 错误呢? 解析不了的就打个 warning 然后 ignore
或者考虑在解析节点的时候 catch 错误呢? 解析不了的就打个 warning 然后 ignore
catch 是需要的,你可以提个 PR 修复下吗
好的, assign 给我吧
@schneiderlin Is there any progress?
is there done?i want to try it if nobody want do it.
@walkinggo Go ahead!
I think this issue has been resolved. Should it be closed?