java程序中运行无限次的Cassandra查询,即使只调用一次

java程序中运行无限次的Cassandra查询,即使只调用一次,java,cassandra,Java,Cassandra,我将以下代码作为java程序运行。这个查询运行了无限次,尽管它只被调用了一次,但我不知道为什么。它在第一次查询期间删除键空间,当它再次运行时(它不应该这样做),它会多次给出键空间不存在的异常 我应该如何使查询只运行一次 Session session=cassandraSessionFactory.getSession(); String query = "drop keyspace "+keyspace_name"; session.execute(query); session.close(

我将以下代码作为java程序运行。这个查询运行了无限次,尽管它只被调用了一次,但我不知道为什么。它在第一次查询期间删除键空间,当它再次运行时(它不应该这样做),它会多次给出键空间不存在的异常

我应该如何使查询只运行一次

Session session=cassandraSessionFactory.getSession();
String query = "drop keyspace "+keyspace_name";
session.execute(query);
session.close();
这里是异常堆栈跟踪,它会持续打印多次,只有在手动停止时才会停止

23:24:55,654  INFO BackendOperation:75 - Temporary exception during backend operation [messageReading@0:0]. Attempting backoff retry.
com.thinkaurelius.titan.diskstorage.TemporaryBackendException: Temporary failure in storage backend
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxKeyColumnValueStore.getNamesSlice(AstyanaxKeyColumnValueStore.java:114)
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxKeyColumnValueStore.getNamesSlice(AstyanaxKeyColumnValueStore.java:78)
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxKeyColumnValueStore.getSlice(AstyanaxKeyColumnValueStore.java:67)
    at com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller$1.call(KCVSLog.java:769)
    at com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller$1.call(KCVSLog.java:766)
    at com.thinkaurelius.titan.diskstorage.util.BackendOperation.execute(BackendOperation.java:133)
    at com.thinkaurelius.titan.diskstorage.util.BackendOperation$1.call(BackendOperation.java:147)
    at com.thinkaurelius.titan.diskstorage.util.BackendOperation.executeDirect(BackendOperation.java:56)
    at com.thinkaurelius.titan.diskstorage.util.BackendOperation.execute(BackendOperation.java:42)
    at com.thinkaurelius.titan.diskstorage.util.BackendOperation.execute(BackendOperation.java:144)
    at com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller.run(KCVSLog.java:703)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=0(0), attempts=1]InvalidRequestException(why:Keyspace keyspace_name does not exist)
    at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
    at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:65)
    at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:28)
    at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$ThriftConnection.execute(ThriftSyncConnectionFactoryImpl.java:153)
    at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:119)
    at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352)
    at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$4.execute(ThriftColumnFamilyQueryImpl.java:538)
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxKeyColumnValueStore.getNamesSlice(AstyanaxKeyColumnValueStore.java:112)
    ... 17 more
Caused by: InvalidRequestException(why:Keyspace keyspace_name does not exist)
    at org.apache.cassandra.thrift.Cassandra$multiget_slice_result$multiget_slice_resultStandardScheme.read(Cassandra.java:14678)
    at org.apache.cassandra.thrift.Cassandra$multiget_slice_result$multiget_slice_resultStandardScheme.read(Cassandra.java:14633)
    at org.apache.cassandra.thrift.Cassandra$multiget_slice_result.read(Cassandra.java:14559)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_multiget_slice(Cassandra.java:741)
    at org.apache.cassandra.thrift.Cassandra$Client.multiget_slice(Cassandra.java:725)
    at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$4$1.internalExecute(ThriftColumnFamilyQueryImpl.java:544)
    at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$4$1.internalExecute(ThriftColumnFamilyQueryImpl.java:541)
    at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60)
    ... 23 more

嗯,代码似乎是在调用堆栈中某个地方的循环中调用的。很难知道你在哪里共享了这么有限的代码。您是否尝试使用调试器进行调查?@MickMnemonic在写入这些行的代码中没有循环。堆栈跟踪包括一个
ThreadPoolExecutor
,因此可能只有多个并行线程运行同一查询。在任何情况下,这都只是猜测而不了解您的应用程序。您是否在删除键空间之前关闭了与Titan graph的所有连接,即
graph.close()
?此外,如果您正在运行Titan服务器,您可能需要在删除键空间之前关闭该服务器。嗯,代码似乎是在调用堆栈中某个地方的循环中调用的。很难知道你在哪里共享了这么有限的代码。您是否尝试使用调试器进行调查?@MickMnemonic在写入这些行的代码中没有循环。堆栈跟踪包括一个
ThreadPoolExecutor
,因此可能只有多个并行线程运行同一查询。在任何情况下,这都只是猜测而不了解您的应用程序。您是否在删除键空间之前关闭了与Titan graph的所有连接,即
graph.close()
?此外,如果您正在运行Titan服务器,则可能需要在删除键空间之前关闭该服务器。