Reputation: 12205
I have to update several thousand of records in a Cassandra table and I use executeAsync(BoundStatement)
method however I got the error Pool is busy (no available connection and the queue has reached its max size 256)
see below the full details.$
What is the best way to correctly handle this type of execution? What about increasing the Cassandra query queue size and the wait time in the queue?
Exception in thread "Thread-6" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: cassandra2/172.18.0.17:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra2/172.18.0.17] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra4/172.18.0.18:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra4/172.18.0.18] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra1/172.18.0.11:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra1/172.18.0.11] Pool is busy (no available connection and the queue has reached its max size 256)))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:75)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:28)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:28)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:236)
I use a cluster with 3 nodes, QUORUM consistency and replication factor of 3.
Upvotes: 1
Views: 1319
Reputation: 16576
You could increase your queue but that really just puts off the problem. You probably would want to just retry any such requests but it may be in your best interests to use a semaphore and only permit a certain number of requests to be inflight at a time rather than queueing up all the inserts at once.
You could also use a mechanism like this if ordering is important
Spark Cassandra Connector slidingIteartor for controlling the execution of many asynchronous requests
Upvotes: 2
Reputation: 1414
There are two options:
Upvotes: 2