cassandra-rs
cassandra-rs copied to clipboard
[0.16] the ability to specify a default consistency level for statements / batches on either Cluster or Session
Currently, the underlying C++ library defaults everything to a consistency level of ONE. (https://docs.datastax.com/en/developer/cpp-driver/2.15/api/struct.CassStatement/#function-cass_statement_set_consistency)
It doesn't allow you to specify a more sensible default. Since we're wrapping this library, we could very easily support setting a consistency level on a Cluster or Session level, and propagating that change down into the execution handler.
This has been a footgun for us, where we forget to set consistency level on a query to have it be doing ONE reads/writes instead of QUORUM read/writes. By providing an API that lets us set the default consistency level, this will let users of the library opt out of this nonsense default from the C++ driver, and not have to worry about setting the consistency level with each statement they execute. Perhaps even we should be opinionated here and say that the default consistency level should be LOCAL_QUORUM
, because honestly, ONE
is an insane default that can lead to data loss/inconsistency.
Our code right now has a LOT of x.set_consistency(cassandra::Consistency::LOCAL_QUORUM)?;
and it's pretty dangerous if forgotten.
Very happy with this proposal, and yes a sensible default default for us would be LOCAL_QUORUM
too.