RoundRobinServerManager.HasNext is inaccurate #74

dlbromen opened this Issue Oct 10, 2012 · 1 comment

2 participants


Commit 6b8cfa9 introduced another bug.

For example, say there are 10 servers. If, for whatever reason 5 or more of them go down and are blacklisted (and ultimately removed from _serverQueue by Next() method), then _serverQueue.Count [5] - blacklist.Count [5] is NOT > 0, so HasNext returns false. In reality there are 5 up.

I see three possible solutions:
1. Use _servers.Count instead of _serverQueue.Count. Basically, take the total number of servers, subtract the blacklist, and that should get you the non-blacklisted _serverQueue count. Only concern here would be since _servers is a List, it is possible for the same server to show up in there twice, but only once in the Blacklist (HashSet) and therefore the result could still be off. Not sure if this is a valid use case.
2. Go back to using _serverQueue.Count > 0 by itself, but cleanse the _serverQueue in the BlackList method. This way _serverQueue is always accurate.
3. Loop through the _serverQueue every time, checking each server against the blacklist. I don't like this one, but it would work.

@nberardi, any preference or thoughts? I like solution 2. I'll submit a pull after we've agreed on a solution.

@dlbromen dlbromen added a commit to nativex/fluentcassandra that referenced this issue Oct 11, 2012
@dlbromen dlbromen Fixing issue #74. Clean up the _serverQueue on blacklist; use only _s…
…erverQueue.Count to determine HasNext.
@nberardi nberardi closed this Oct 11, 2012
@nberardi nberardi was assigned Oct 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment