fix prepared results bug
@@ -10,6 +10,7 @@ use async_trait::async_trait;
use cassandra_protocol::events::ServerEvent;
use cassandra_protocol::frame::message_error::{ErrorBody, ErrorType, UnpreparedError};
use cassandra_protocol::frame::message_execute::BodyReqExecuteOwned;
+use cassandra_protocol::frame::message_result::BodyResResultPrepared;
use cassandra_protocol::frame::message_result::PreparedMetadata;
use cassandra_protocol::frame::{Opcode, Version};
use cassandra_protocol::query::QueryParams;
@@ -487,32 +488,32 @@ impl CassandraSinkCluster {
)
.await?;
- if !prepare_responses.windows(2).all(|w| w[0] == w[1]) {
- let err_str = prepare_responses
+ let prepared_results: Vec<&mut Box<BodyResResultPrepared>> = prepare_responses
.iter_mut()
- .filter_map(|response| {
+ .filter_map(|message| {
if let Some(Frame::Cassandra(CassandraFrame {
- operation:
- CassandraOperation::Result(CassandraResult::Prepared(prepared)),
+ operation: CassandraOperation::Result(CassandraResult::Prepared(prepared)),
..
- })) = response.frame()
+ })) = message.frame()
{
- Some(format!("\n{:?}", prepared))
+ Some(prepared)
} else {
None
}
})
+ .collect();
+
+ if !prepared_results.windows(2).all(|w| w[0] == w[1]) {
+ let err_str = prepared_results
+ .iter()
+ .map(|p| format!("\n{:?}", p))
.collect::<String>();
- if cfg!(test) {
- panic!("{}", err_str);
- } else {
tracing::error!(
"Nodes did not return the same response to PREPARE statement {err_str}"
);
}
}
- }
// When the server indicates that it is ready for normal operation via Ready or AuthSuccess,
// we have succesfully collected an entire handshake so we mark the handshake as complete.
