Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2486

Client does not load balance requests across available connections

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.4.8, 3.4.9
    • Fix Version/s: None
    • Component/s: driver
    • Labels:
      None

      Description

      The client does not load balance requests across connections in a threadpool which cause a request failing with timeout even when a connection is available. To verify this, the following test fails:

      @Test
      public void shouldBalanceConcurrentRequestsAcrossConnections() throws InterruptedException {
          final int connPoolSize = 16;
          final Cluster cluster = TestClientFactory.build()
                  .minConnectionPoolSize(connPoolSize)
                  .maxConnectionPoolSize(connPoolSize)
                  .create();
          final Client.ClusteredClient client = cluster.connect();
          client.init();
      
          try {
              final RequestMessage.Builder request = client.buildMessage(RequestMessage.build(Tokens.OPS_EVAL))
                      .add(Tokens.ARGS_GREMLIN, "Thread.sleep(5000)");
              final Callable<Connection> sendQueryCallable = () -> client.chooseConnection(request.create());
              final List<Callable<Connection>> listOfTasks = new ArrayList<>();
              for (int i=0; i<connPoolSize; i++) {
                  listOfTasks.add(sendQueryCallable);
              }
      
              Set<String> channels = new HashSet<>();
              final List<Future<Connection>> executorSubmitFutures = executorServiceForTesting.invokeAll(listOfTasks);
              executorSubmitFutures.parallelStream().map(fut -> {
                  try {
                      return fut.get();
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  } catch (ExecutionException e) {
                      e.printStackTrace();
                  }
                  return null;
              }).forEach(conn -> channels.add(conn.getChannelId()));
      
              
              System.out.println(channels.size());
      
          } finally {
              cluster.close();
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              divijvaidya Divij Vaidya
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: