I am getting cassandra OperationTimedOutException
while dropping keyspace. Although I have given 60000 Milliseconds (1 minute) timeOut
to block until I get Future
object from cassandra executeAsync
. But immediately it throws timeoutexception
without waiting complete 1 minute.
This is how I am removing keyspace using java -
List<KeyspaceMetadata> keyspaceMetadataList = cluster.getMetadata().getKeyspaces();
for(KeyspaceMetadata ks: keyspaceMetadataList)
{
if (ks.getName().startsWith("system"))
{
continue;
}
try
{
session.executeAsync("drop keyspace " + ks.getName()).get(1000 * 60, TimeUnit.MILLISECONDS);
log.info("Dropped Keyspace: " + ks.getName());
}
catch( InterruptedException | ExecutionException | TimeoutException e )
{
log.error("Something went wrong: " + e);
}
}
You can see the below-given line, where I forcefully telling the call to wait at least 60 seconds, but even before that, I got TimeOutException
.
session.executeAsync("drop keyspace " + ks.getName()).get(1000 * 60, TimeUnit.MILLISECONDS);
I am not sure if this is the right way for increasing timeout programmatically. please let me know if any other good way to do so.
It's better not to do multiple modifications in the same time (like you're doing via executeAsync
). When you're modifying schema in the distributed system, schema changes should settle, and all nodes should have agreement between them.
I suggest to modify your code to execute commands via session.execute
instead of async version. And check for schema agreement when all operations are done - there is a corresponding method in the Metadata
class.