com.datastax.driver.core.exceptions.OperationTimedOutException

1,358 views
Skip to first unread message

Devendra Vishwakarma

unread,
Jun 18, 2018, 7:26:06 AM6/18/18
to DataStax Java Driver for Apache Cassandra User Mailing List
Each time I drop keyspace using java driver, I get the com.datastax.driver.core.exceptions.OperationTimedOutException immediately. Please help.

This is the code - 

List<String> keyspacesDeleted = new ArrayList<>();
List<KeyspaceMetadata> keyspaceMetadataList = cluster.getMetadata().getKeyspaces();
for(KeyspaceMetadata ks: keyspaceMetadataList)
{
if (ks.getName().startsWith("system"))
{
continue;
}
session.execute("drop keyspace " + ks.getName());
keyspacesDeleted.add(ks.getName());
log.info("Dropped Keyspace: " + ks.getName());
}
return keyspacesDeleted;



Exception - 
com.datastax.driver.core.exceptions.OperationTimedOutException: [/127.0.0.1:9042] Timed out waiting for server response
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onTimeout(RequestHandler.java:825) ~[cassandra-driver-core-3.4.0.jar:na]
at com.datastax.driver.core.Connection$ResponseHandler$1.run(Connection.java:1394) ~[cassandra-driver-core-3.4.0.jar:na]
at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:663) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:738) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:466) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

Details of the environment- 
1. Java 1.8
2. cassandra-driver-core-3.4.0.jar
3. apache-cassandra-2.2.6 single node standalone

Alexandre Dutra

unread,
Jun 18, 2018, 8:46:47 AM6/18/18
to java-dri...@lists.datastax.com
Hi,

Dropping a keyspace is an expensive operation that indeed risks timing out more often than not, specially if the keyspace has several tables or views. Here are a few simple things that you can do to work around this issue:
  1. Drop the tables one by one, then drop the keyspace when it's empty;
  2. Raise the driver's default timeout (see instructions here) – you can raise the value to stg as high as 1 minute for expensive operations like a keyspace drop (you might have to raise the server-side timeouts as well).
  3. Retry the operation manually in your code.
Also one last tip: after deleting all the keyspaces, it is a good idea to check for schema agreement before pursuing.

Hope that helps,
Alex

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.
--
Alexandre Dutra
Driver & Tools Engineer @ DataStax

Devendra Vishwakarma

unread,
Jun 18, 2018, 11:54:29 AM6/18/18
to java-dri...@lists.datastax.com
Hi Alex,
All the points you mentioned make sounds to me. Thanks for the input on this.

Devendra
Reply all
Reply to author
Forward
0 new messages