-
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: fix eureka always refreshCluster error #4235
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4235 +/- ##
==========================================
Coverage 48.84% 48.84%
Complexity 3802 3802
==========================================
Files 724 724
Lines 24238 24238
Branches 2972 2971 -1
==========================================
Hits 11839 11839
Misses 11159 11159
Partials 1240 1240 |
这个pr并没有修复bug吧?只不过把异常打印出来了,如果port是-1,不应该去解决为什么是-1的问题吗? |
端口号为-1的问题,seata也解决不了啊,这个是从eureka拿到的数据,服务注册到eureka的数据本身就不合法,但是不应该因为一个实例的数据不合法,让所有的实例都不能刷新啊。 catch的好处是,不会因为某一个实例注册的eureka的,ip端口数据不合法,而导致其他没问题的实例refresh也失败。 |
为何不通过register来防止server注册错误的port,以及在server上寻找为什么是-1的port呢? |
不是很明白你的意思啊。 |
在tc也就是seata-server进行registry的时候进行注册,client这个检查可以保留,以防有新老版本server共存的情况 |
我大概明白你的意思了,你应该是以为tc注册到eureka的ip端口不合法是吧?
但是她这里实际上不是只拿了tc注册的信息,而是eureka上面全部服务的注册信息。我这里出现ip端口不合法也不是因为某个tc不合法,而是其他注册到eureka上面的业务服务导致的。 其实我也不是很明白为啥注册的eureka上的所有服务信息都要保存起来。按道理不是应该只需要保存一下tc的实例信息吗? 而且每10s更新这一大堆实例信息,也会对客户端性能有点影响吧? |
这里做的有点问题,application= clusterName的哪些才需要被遍历,你帮忙一起处理下? |
行 |
…x_eureka_refresh_fail
private void refreshCluster() { | ||
List<Application> applications = getEurekaClient(false).getApplications().getRegisteredApplications(); | ||
private void refreshCluster(String clusterName) { | ||
Application application = getEurekaClient(false).getApplications().getRegisteredApplications(clusterName); |
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.
直接getApplication(clusterName) 是否可以使用? 而不是拿所有的applications里的clustername
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.
试了一下,也可以,不过好像区别不大。
@OverRide
public Application getApplication(String appName) {
return getApplications().getRegisteredApplications(appName);
}
...overy-eureka/src/main/java/io/seata/discovery/registry/eureka/EurekaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
clusterAddressMap = collect; | ||
clusterAddressMap.put(clusterName, list); |
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.
不要put,还是按之前的走,否则在集群切换的时候,之前的集群地址会残留在内存里没法清除
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.
done
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登记
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.
…x_eureka_refresh_fail # Conflicts: # changes/1.5.0.md # changes/en-us/1.5.0.md
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
new InetSocketAddress的时候,会去检查ip和端口,某些特殊情况,传到eureka上面的端口号可能为-1,开发环境偶尔遇到过,然后会一直refreshCluster失败,实际上可能只是某个服务实例传到eureka上面的端口号不正确,导致全部实例全部都无法刷新了。所以在这里catch一下这个检查参数的异常。
Ⅱ. 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