Guarantees of YCQL counters

Hey. So Cassandra doesn’t have super strong guarantees when it comes to counters (single update could potentially be executed twice in case of slowdowns). What are the guarantees YB has to offer? For counters i mean?

YugaByte DB protects against internal retries of the same statement (potentially a non-idempotent statement like a counter column increment) by detecting duplicate writes which may have already succeeded.

In fact, this was indeed an issue earlier, but we fixed it (in 2018) as part of our DIY Jepsen testing efforts.

Note: If at the client-driver level you have turned retries on (which is the default) then, yes, you can have a double increment. To avoid that, retries must be turned off at the client-driver level as well.

Makes sense. So the recommended setting for the client driver is to turn off automatic retries?

Retries are nice for idempotent operations. Maybe you can decide based on that.

Another operation is to use CAS (compare-and-swap) - like SET x = 10 WHERE key = 'k' and x = 9;

Would there be any performance penalties for using CAS type queries?

YugaByte DB implements CAS operations in one roundtrip, compared to 4 for Apache Cassandra, so much more efficient here.

So CAS will be slightly slower than non-CAS operations but not by too much. CAS operations will have to read the value (local read on the leader) before writing while non-CAS operations can simply write (update semantics).