DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

ashok.dcosta_187920 avatar image
ashok.dcosta_187920 asked ·

Does the coordinator enforce consistency level for writes?

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 ?

driverconsistency level
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered ·

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:

Unavailable

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)

Timeout error

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)"

Failure error

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!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

smadhavan avatar image
smadhavan answered ·

@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!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

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 ?

0 Likes 0 · ·

A friendly note to let you know that I've converted your post to a comment since it's not an "answer". Cheers!

0 Likes 0 · ·