Uploaded image for project: 'DataStax Java Driver for Apache Cassandra'
  1. JAVA-1195

NoHostException after some connection failures or Query failures

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      i am using cassandra 2.0.9 and datastax java driver 3.0.0.
      I had too many NoHostAvailableException after some ReadTimeOutException and WriteTimeOutException.NoHostException occurred even though cassandra is normal and listening in 9160 and 9042 ports.
      It says some connections are closed, if connections are closed then it should establish new connections for processing. i haven't set connectionsPerHost. My code to connect cassandra using driver

      private static Cluster constructCluster(String hostName,String port) {
              String[] hostNames = hostName.split(",");
              SocketOptions sOptions = new SocketOptions();
              sOptions.setKeepAlive(true);
              QueryOptions qOptions = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM)
                      .setFetchSize(500);
              LatencyAwarePolicy loadBalancingPolicy = LatencyAwarePolicy.builder(DCAwareRoundRobinPolicy.builder().withLocalDc(defaultDC).build())
                      .build();
              Cluster cluster = Cluster.builder()
                      .addContactPoints(hostNames)
                      .withLoadBalancingPolicy(loadBalancingPolicy)
                      .withPoolingOptions(new PoolingOptions())
                      .withQueryOptions(qOptions)
                      .withReconnectionPolicy(new ConstantReconnectionPolicy(TimeUnit.SECONDS.toMillis(5)))
                      .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE))
                      .withSocketOptions(sOptions)
                      .build();
              LOGGER.log(Level.SEVERE, "host name {0}", hostName);
              return cluster;
          }
      

      My exception trace

      com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.250.165:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.165] Connection has been closed), /192.168.249.91:9042, /192.168.251.84:9042 [only showing errors of first 3 hosts, use getErrors() for more details])
          at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
          at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
          at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
          at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
          at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
      

      another exception trace

      com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.251.84:9042 (com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection (you may want to increase the driver number of per-host connections)), /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.250.165:9042, /192.168.249.91:9042 [only showing errors of first 3 hosts, use getErrors() for more details])
      	at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
      	at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
      	at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
      	at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
      	at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
      

      I cannot reproduce this issue later.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rishikesan Rishikesan
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: