Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

round-robin balancer has a thread-safety problem #19

Closed
biningo opened this issue Nov 23, 2023 · 2 comments · Fixed by #20
Closed

round-robin balancer has a thread-safety problem #19

biningo opened this issue Nov 23, 2023 · 2 comments · Fixed by #20

Comments

@biningo
Copy link
Contributor

biningo commented Nov 23, 2023

Hi~ @zehuamama
I found that round-robin balancer has a thread-safety problem, increasing the current index but the lock is read lock. This may cause the result we get from the round-robin balancer may not be what we want.

Reference: https://github.com/zehuamama/balancer/blob/6e8ef295bbbc76b6815d9f297b26352aeaf37fd4/balancer/round_robin.go#L35C5-L35C5

@biningo
Copy link
Contributor Author

biningo commented Nov 23, 2023

I think could use the Go atomic package to slove this ploblem.

@hyman-m
Copy link
Owner

hyman-m commented Nov 23, 2023

I think could use the Go atomic package to slove this ploblem.

嗯,非常感谢,我疏忽这个问题,支持使用原子命令,你可以提个 pr,我帮你合入

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

Successfully merging a pull request may close this issue.

2 participants