2016-09-14 72 views
0

我现在正在对将数据保存到cassandra的API端点执行负载测试。一般来说它工作得很好,但是当我执行异步插入操作我得到错误回调以下消息:Cassandra Python驱动程序错误回调显示没有错误

ERROR:root:Query '<BatchStatement type=UNLOGGED, statements=382, consistency=ONE>' failed: errors={}, last_host=XXXXX 

我执行批量插入方式如下:

query_template = self.query_template(table, columns, values, ttl, insertion_timestamp) 

statement = self.session.prepare(query_template) 
statement.consistency_level = self.write_consistency_level 
batch = BatchStatement(batch_type=BatchType.UNLOGGED, retry_policy=RetryPolicy.RETRY, 
          consistency_level=self.write_consistency_level) 
for elem in list_of_dictionary: 
    values = [elem[key] for key in field_list] 
    batch.add(statement, values) 

if async: 
    future = self.session.execute_async(batch, values) 
    future.add_errback(error_handler, batch) 
else: 
    self.session.execute(batch, values) 

与错误回调处理程序:

def default_error_handler(exc, batch): 
    """ 
    Default callback function that is triggered when the cassandra async operation failed 
    :param exception: 
    """ 

    logging.error("Query '%s' failed: %s", batch, exc) 

有没有人有线索?

回答

0

所以我发现了这个问题。

这是OperationTimedOut类型的客户端错误。你可以在这里找到:

https://github.com/datastax/python-driver/blob/1fd961a55a06a3ab739a3995d09c53a1b0e35fb5/cassandra/init.py

我建议登录此外,异常的类型在你的回调函数这样

def default_error_handler(exc, batch): 
    """ 
    Default callback function that is triggered when the cassandra async operation failed 
    :param exception: 
    """ 


    logging.error("Batch '%s' failed with exception '%s' of type '%s' ", batch, exc, type(exc)) 

现在我会尽量解决我们的问题!

相关问题