soumyadeep sarkar
soumyadeep sarkar

Reputation: 572

All the TCP connection b/w DataStax driver to the Cassandra Remain in Active close state . i.e TIME_WAIT state.

The setup:

Web server Apache Tomcat
RestFull web services
Using DataStax java driver 2.0

Database -2-node Cassandra 2.0.7.31 cluster
-replicas=1

Problem

After sending set of 1500 request more than three times. I got error at the tomcat log

     com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /10.181.13.239 ([/10.181.13.239] Unexpected exception triggered))
                at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:64)
                at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:214)
                at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:169)
                at com.jpmc.es.rtm.storage.impl.EventExtract.main(EventExtract.java:36)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
    Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /10.181.13.239 ([/10.181.13.239] Unexpected exception triggered))
                at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:98)
                at com.datastax.driver.core.RequestHandler$1.run(RequestHandler.java:165)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
                at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

Observation After this state of tomcat. All the further request attaining the same fate. That is drivers are not able to send my insert request to cassandra.

After executing net stat command i find that the all the TCP connection b/w web server and the Cassandra are in TIMED_WAIT state.

What could be the reason ? why Datastax driver is not able to take back the connection back to the pool? or why does the Cassandra is engaging all the connection form its client.

Thanks in Advance

Upvotes: 0

Views: 563

Answers (1)

soumyadeep sarkar
soumyadeep sarkar

Reputation: 572

The connection was increasing Due to calling creating multiple session for each request. Now it is working Fine.

         builder = new Cluster.Builder().
                addContactPoints("192.168.114.42");

        builder.withPoolingOptions(new PoolingOptions().setCoreConnectionsPerHost(
                HostDistance.LOCAL, new PoolingOptions().getMaxConnectionsPerHost(HostDistance.LOCAL)));

        cluster = builder
                .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
                .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
                .build();
        session = cluster.connect("demodb");

Now Driver is maintain 17-26 number of connection irrespective of number of transaction.

Upvotes: 0

Related Questions