Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Done
-
3.1.0-incubating
-
None
Description
Bring up two gremlin-server
Create a Cluster with these two servers, by default LoadBalancingStrategy.RoundRobin() is used.
Create a client and make queries.
Notice that all requests go to the second server.
this.cluster.loadBalancingStrategy().select(msg).next() is called twice in Client.chooseConnection(), so always the second Host is used.
The following seems to work
Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java index 8c80b8a..17c9a99 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java @@ -341,7 +341,7 @@ public abstract class Client { final Iterator<Host> possibleHosts = this.cluster.loadBalancingStrategy().select(msg); if (!possibleHosts.hasNext()) throw new TimeoutException("Timed out waiting for an available host."); - final Host bestHost = this.cluster.loadBalancingStrategy().select(msg).next(); + final Host bestHost = possibleHosts.next(); final ConnectionPool pool = hostConnectionPools.get(bestHost); return pool.borrowConnection(cluster.connectionPoolSettings().maxWaitForConnection, TimeUnit.MILLISECONDS); }
Attachments
Issue Links
- relates to
-
TINKERPOP-1126 A single Host spawns many reconnect tasks
- Closed
-
TINKERPOP-1127 client fails to reconnect to restarted server
- Closed