Retry procedure when prepared statement execution fails

17 views
Skip to first unread message

Mike

unread,
Jul 24, 2016, 12:01:49 AM7/24/16
to DataStax C++ Driver for Apache Cassandra User Mailing List
I am working on converting a C module that currently talks to Cassandra using the thrift interface to using the DataStax C++ driver version 2.4.1.

With the thrift interface when executing a prepared statement the sequence is:

1. Prepare the statement, which returns the compiled statement’s associated “itemId”.
2. Execute the prepared statement multiple times with various bound parameters, using said “itemId”.
3. If prepared execute fails because the coordinator node being used is not currently available, then the prepared execute cannot be directly retried on another coordinator, the statement must first be prepared again on the new coordinator before execution can be retried.

With the DataStax C++ driver is something similar required? Specifically:

1. Prepare the statement with, “cass_session_prepare”.
2. Execute the statement with, “cass_session_execute”.
3. If prepared execution fails because one of the nodes has gone down, do I need to prepare the statement again before retrying execution?

Thanks,
Mike.

Michael Penick

unread,
Jul 25, 2016, 12:18:44 PM7/25/16
to cpp-dri...@lists.datastax.com
"If prepared execution fails because one of the nodes has gone down, do I need to prepare the  statement again before retrying execution?"

No, the DataStax C++ driver automatically handles re-preparing statements on downed nodes. This is a feature supported by the CQL native protocol. The down node sends back a  "Unprepared" response (https://github.com/apache/cassandra/blob/cassandra-3.0/doc/native_protocol_v3.spec#L1016-L1019)  and the driver automatically re-prepares before executing the statement.

Mike




--
You received this message because you are subscribed to the Google Groups "DataStax C++ Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpp-driver-us...@lists.datastax.com.

Mike Fox

unread,
Jul 25, 2016, 6:42:24 PM7/25/16
to cpp-dri...@lists.datastax.com
Great, thanks Mike.

Mike.
Reply all
Reply to author
Forward
0 new messages