Cassandra doesn't wait for nodes to be available

Viewed 384

I'm using the datastax driver for java:

@Dao
public interface MyDao {
    @Insert
    CompletableFuture<Void> save(MyEntity entity);
    ...
}

public class MyDaoTests {
    
    @Test
    public void myTest() {
    ...
    List<CompletableFuture<Void>> futureList = myEntityList.parallelStream()
             .map((myEntity) -> meterDataMapper.myDao().save(myEntity))
             .collect(Collectors.toList());
    CompletableFuture.allOf(futureList.toArray(CompletableFuture[]::new)).join();
    ...
   }
}

When I execute the test, I get this error:
java.util.concurrent.CompletionException: com.datastax.oss.driver.api.core.NoNodeAvailableException: No node was available to execute the query

Is there a way to configure the driver/session to wait for available nodes?

Further information:

  • My test size is about 2500000 entities (myEntityList).
  • Synchronous inserts work fine, but they're way too slow.
  • I want to solve this with the datastax-java-driver mapper, annotation-based, as simple as possible.
  • Driver Version: 4.9.0
1 Answers

The NoNodeAvailableException is returned when the driver has marked all nodes as down or unresponsive, or when the contact points are invalid (not likely in your case).

It isn't a case of making the driver wait for nodes to come back online. Since the driver thinks all the nodes are unavailable, it doesn't even try to connect to any nodes.

Review the logs on the nodes for clues as to why they're unresponsive. If you're seeing long GC pauses and/or dropped reads/mutations, they are a sign that the nodes are overloaded. If you're running a load test, consider throttling the throughput back so as not to overload your cluster. Cheers!

Related