【问题标题】:Cassandra Python Driver Error callback shows No errorCassandra Python 驱动程序错误回调显示没有错误
【发布时间】:2017-01-22 02:25:43
【问题描述】:

我现在正在对将数据保存到 cassandra 的 API 端点执行负载测试。一般来说,它运行良好,但是当我执行异步插入操作时,我在错误回调中收到以下消息:

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)

有人知道吗?

【问题讨论】:

    标签: python cassandra datastax


    【解决方案1】:

    所以我发现了问题。

    这是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))
    

    我现在将尝试解决我们的问题!

    【讨论】:

      猜你喜欢
      • 2015-03-26
      • 2016-12-25
      • 2014-04-05
      • 1970-01-01
      • 1970-01-01
      • 2018-11-14
      • 2022-09-27
      • 1970-01-01
      • 2015-09-26
      相关资源
      最近更新 更多