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

failover重试机制(默认)且只有两个Invoker时,invoker选择有问题 #1737

Closed
feelwing1314 opened this issue May 4, 2018 · 4 comments

Comments

@feelwing1314
Copy link
Contributor

当采用failover重试机制(默认)且只有两个Invoker(Provider)时,不论配置了什么负载均衡loadbalance策略,都会退化成轮询策略。但是retry重试时选择Invoker的逻辑有问题,源码在AbstractClusterInvoker.java的doSelect()方法中:
if (invokers.size() == 2 && selected != null && !selected.isEmpty()) {
return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
}
假设有两个可选invoke,分别为:
10.0.0.1:20884,10.0.0.1:20886;
那么N次选择的invoke如下:
10.0.0.1:20884
10.0.0.1:20886
10.0.0.1:20886
10.0.0.1:20886
10.0.0.1:20886
... ...
即除了第1次,其他N-1次都是选择第二个Invoker。

修改建议:

return selected.get(0) == invokers.get(0) ?
改为
return selected.get(selected.size()-1) == invokers.get(0) ?
即每次重新选择时与前一次选择的Invoker比较,而不是与第一次选择的Invoker比较;

@mzorro
Copy link
Contributor

mzorro commented May 6, 2018

经过测试,确实是有这个问题

@carryxyh
Copy link
Member

@ralf0131
Fixed, able to close.

@ralf0131
Copy link
Contributor

@carryxyh Thanks, I checked the latest code, I has been fixed by #1759

@carryxyh
Copy link
Member

: )
u are welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants