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

lalb在有可用节点的情况下仍可能触发“[E112]Fail to select server...” #2427

Open
FancyJan opened this issue Oct 26, 2023 · 1 comment

Comments

@FancyJan
Copy link
Contributor

FancyJan commented Oct 26, 2023

Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)
lalb在SelectServer的循环中,如果选到不可用的节点,在一定条件下会继续尝试节点树的右子树:
判断是否可以进入右子树

例如某一时刻节点树只有两个节点,0号不可用1号可用。
按照现在的逻辑如果第一次选中了0,那么这次选择会失败,因为0没有可用的右子树,但是节点树里确实有可用的1号节点。如果连续两次(n=2)一开始选到0,那这一次lb会失败。

在有节点探活失败的情况下可能发生,虽然概率不大,但运气不好每次都选中不可用节点的概率确实存在,尤其是在下游节点不多的情况下。

Describe the solution you'd like (描述你期望的解决方法)
在单次Select循环中,如果节点不可用即判断是否可以进入右子树为false,
那么尝试进入左子树作为兜底,例如:
else { dice = butil::fast_rand_less_than(left); index = index * 2 + 1; if (index < n) { continue; } }

Describe alternatives you've considered (描述你想到的折衷方案)
lalb在节点数较少时,多尝试几轮Select循环

Additional context/screenshots (更多上下文/截图)

@FancyJan
Copy link
Contributor Author

近期会提交一个pr

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

1 participant