Cassandra Query Failures: All host(s) tried for query failed (no host was tried)
Asked Answered
D

1

6

I am not able to do queries against the Cassandra Node. I am able to make the connection to the cluster and connect. However while doing the the query, it fails

Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)
at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:217)
at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:44)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:276)
at com.datastax.driver.core.RequestHandler.startNewExecution(RequestHandler.java:117)
at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:93)
at com.datastax.driver.core.SessionManager.executeAsync(SessionManager.java:127)
... 3 more

This is how I am connecting to the cluster:

    List<String> servers = config.getCassandraServers();
    Builder builder = Cluster.builder();
    for (String server : servers) {
        builder.addContactPoints(server);
    }

    PoolingOptions opts = new PoolingOptions();
    opts.setCoreConnectionsPerHost(HostDistance.LOCAL, opts.getCoreConnectionsPerHost(HostDistance.LOCAL));

    // setup socket exceptions
    SocketOptions socketOpts = new SocketOptions();
    socketOpts.setReceiveBufferSize(1048576);
    socketOpts.setSendBufferSize(1048576);
    socketOpts.setTcpNoDelay(false);

    cluster = builder.withSocketOptions(socketOpts)
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withPoolingOptions(opts)
            .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
            .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))
            .build();

    cluster.connect();

I am using latest stable version of Cassandra 2.2.3 with the Datastax driver:

<dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>2.1.8</version>
</dependency>

Any pointers are highly appreciated

Thanks Masti

Disloyal answered 12/11, 2015 at 0:33 Comment(2)
Try reading datastax.com/dev/blog/cassandra-error-handling-done-rightAlitta
I read that article and that does not seem to answer the question in my opinion. While I understand that it is not able to connect, my scenario is that the cluster can built and am able to connect (able to print the node it is connected to). However, when I do the query (simple select query), it fails with the error before. Could it be because it lost the connection?Disloyal
D
3

Here is the solve: Issue was with

.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))

Here I only have a single node in AWS cloud to test my adapter and it was throwing Cassandra off. Removing that solves the issue

Thanks

Disloyal answered 12/11, 2015 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.