Cassandra Python Driver Error callback shows No error
<p>I'm right now performing load tests on an API endpoint that saves data into cassandra. In general it works well, but when I perform async insert operations I get the following messages on the error callback:</p>

<pre><code>ERROR:root:Query '&lt;BatchStatement type=UNLOGGED, statements=382, consistency=ONE&gt;' failed: errors={}, last_host=XXXXX
</code></pre>

<p>I perform batch insert the following way:</p>

<pre><code>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)
</code></pre>

<p>With the error callback handler:</p>

<pre><code>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)
</code></pre>

<p>Does anyone have a clue?</p>

<p>So I found out the issue.</p>

<p>It is a client side error of the type <code>OperationTimedOut</code>. You can find it in here:</p>

<p><a href="https://github.com/datastax/python-driver/blob/1fd961a55a06a3ab739a3995d09c53a1b0e35fb5/cassandra/__init__.py" rel="nofollow">https://github.com/datastax/python-driver/blob/1fd961a55a06a3ab739a3995d09c53a1b0e35fb5/cassandra/<strong>init</strong>.py</a></p>

<p>I suggest to log in addition the type of the exception in your callback handler like this</p>

<pre><code>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))
</code></pre>

<p>I will now try to solve our issues!</p>

python cassandra datastax