Does the coordinator enforces consistency levels? For example consistency level is "Two" will it wait for the write operation to complete on 2 nodes ? If yes what happens if only one node responds will it return an error ?
Bringing together the Apache Cassandra experts from the community and DataStax.
Want to learn? Have a question? Want to share your expertise? You are in the right place!
Not sure where to begin? Getting Started
Does the coordinator enforces consistency levels? For example consistency level is "Two" will it wait for the write operation to complete on 2 nodes ? If yes what happens if only one node responds will it return an error ?
The consistency level for write requests determines the number of replicas which must respond to the coordinator with an acknowledgment that the mutation was written to (a) the commitlog
and (b) the memtable so "enforce" is not quite the right word for it.
The driver will report an exception depending on the error that occurred. Using the Java driver for illustration purposes, the following exceptions are reported by the driver in the application logs:
In this situation the request reached the coordinator but not enough replicas were available to satisfy the the consistency level requested.
An example error message looks like this:
UnavailableException: Not enough replicas available for query at consistency TWO (2 required but only 0 alive)
In this situation the request reached the coordinator but one or more replicas were too slow to respond within write_request_timeout_in_ms
.
An example error message looks like this:
WriteTimeoutException: Cassandra timeout during SIMPLE write query at consistency LOCAL_QUORUM (2 replica were required but only 1 acknowledged the write)"
This is a non-timeout error and occurs when some replicas replied with an error. The kind of errors that could trigger this could be one of the replicas had a running out of disk space or a replica experiencing a hardware failure.
An example error message looks like this:
WriteFailureException: Cassandra failure during write query at consistency QUORUM (4 responses were required but only 3 replica responded, 1 failed)
For more info, see How write requests are accomplished in Cassandra. There's explanation of the server-side exceptions which result in driver errors in the Java driver Retries page. For other drivers, see the respective driver's documentation in the DataStax drivers matrix page. Cheers!
@ashok.dcosta_187920, the coordinator sends a write request to all replicas that own the row being written. As long as all replica nodes are up and available, they will get the write regardless of the consistency level specified by the client. The write consistency level determines how many replica nodes must respond with a success acknowledgment in order for the write to be considered successful.
For further reading, please refer to this documentation. Hope that helps!
Will there be a case that an error is returned it is not able to write to all the replicas or if the consistency level is not met? I am trying to understand if it is not able to process the transaction for a reason what will it return ?
A friendly note to let you know that I've converted your post to a comment since it's not an "answer". Cheers!
6 People are following this question.
When a write timeout occurs, does it mean the subsequent read will fail?
Does the Java driver randomly route requests to nodes in all DCs?
What is the optimal concurrency level to use with the Python driver?
How can I append or prepend to a Collection using Java Driver DAO?
Server timeout during read query at consistency LocalOne (0 replica(s) responded over 1 required)
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2022 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use