Skip to content

com.datastax.oss.driver.api.core.NoNodeAvailableException: No node was available to execute the query #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dinchand opened this issue Oct 31, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@dinchand
Copy link

dinchand commented Oct 31, 2023

I am trying to use the new version of liquibase-cassandra which uses this driver. However I keep getting the com.datastax.oss.driver.api.core.NoNodeAvailableException: No node was available to execute the query So created a small snippet only with the driver which also results in the same error.

public class HelloCassandra {
    public static void main(final String[] args) throws SQLException {
        // Used driver: com.ing.data.cassandra.cassandra.jdbc.CassandraDriver
        final String url = "jdbc:cassandra://node1.dc1-llds-1-tst.cassandra.xx:9142/contacting?configfile=/Users/BO55NK/IdeaProjects/untitled/src/main/resources/test.conf";
       
        final Connection connection = DriverManager.getConnection(url);
        connection.prepareStatement("Select * from contacting.contacting_configs").executeQuery();
    }
}

My test.conf looks like this

datastax-java-driver {

  basic.load-balancing-policy {
    class = DefaultLoadBalancingPolicy
    local-datacenter: DC1
  }
  basic.session-keyspace = "contacting"
  basic.request {
    timeout = 20 seconds
    consistency = LOCAL_ONE

  }
  advanced.auth-provider {
    class = PlainTextAuthProvider
    username: xxx_owner
    password: "xxxxxxx"
  }
  advanced.ssl-engine-factory {
    class = DefaultSslEngineFactory
    hostname-validation = false

    truststore-path = /resources/http-trust.jks
    truststore-password = xxxx
  }
}

What could I be possibly missing ?

@maximevw maximevw added the to investigate Investigation needed label Oct 31, 2023
@maximevw
Copy link
Collaborator

maximevw commented Nov 1, 2023

Hello @dinchand,

I found a serious lead explaining the issue and it's neither related to SSL nor your configuration (which seems totally valid).

When a configuration file is present, the JDBC wrapper discards a lot of other parameters, including localdatacenter because for this one it should rely on the parameter basic.load-balancing-policy.local-datacenter from the configuration file. But when I checked the driver context in the session in this specific case, the property localDataCentersFromBuilder was not set as expected.

But I found this in the documentation of the configuration file about local-datacenter property:

This can also be specified programmatically with SessionBuilder.withLocalDatacenter. If both are specified, the programmatic value takes precedence.

Also the current code of the JDBC wrapper always call SessionBuilder.withLocalDatacenter() even if a configuration file is used and the localdatacenter parameter is discarded. So, the local data center used in the load balancing policy becomes empty and the queries failed with the NoNodeAvailableException.

I'm working on a patch to solve this, stay tuned.

@maximevw maximevw added bug Something isn't working and removed to investigate Investigation needed labels Nov 1, 2023
maximevw added a commit that referenced this issue Nov 1, 2023
- handle VARBINARY and LONGVARBINARY types with either ByteArrayInputStream
or byte[] in the methods CassandraPreparedStatement.setObject().
- fix configuration of the local datacenter using the one from the
configuration file when such a file is used.
@maximevw
Copy link
Collaborator

maximevw commented Nov 1, 2023

@dinchand, I just released the version 4.10.2 including a fix for this issue. The version will also be available in Maven Central in next hours.

@maximevw maximevw closed this as completed Nov 1, 2023
maximevw added a commit that referenced this issue Nov 1, 2023
- handle VARBINARY and LONGVARBINARY types with either ByteArrayInputStream
or byte[] in the methods CassandraPreparedStatement.setObject().
- fix configuration of the local datacenter using the one from the
configuration file when such a file is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants