2016-09-14 132 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)) 

現在我會盡量解決我們的問題!