You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Tarun Chabarwal <ta...@gmail.com> on 2019/09/18 13:10:28 UTC

Cassandra Counters

Hi

I stumbled on this
<https://docs.datastax.com/en/archived/cql/3.0/cql/ddl/ddl_counters_c.html>
post which says use consistency level ONE with counters. I'm using
cassandra 3 with 3 copies in one data center. I've to support consistent
reads.

Can we do LOCAL_QUORUM read/write against counters ? Is there any downside
of using quorum with counters ?

If we can't use quorum then is it possible to get consistent reads ?


Regards
Tarun Chabarwal

Re: Cassandra Counters

Posted by Federico Razzoli <fe...@gmail.com>.
Hi Tarun,

That documentation page is a bit ambiguous. My understanding of it is that:

* Cassandra guarantees that counters are updated consistently across the
cluster by doing background reads, that don't affect write latency.
* If you use a consistency level stricter than ONE, the same read is done;
the difference is that it's not in background, and your write latency is
affected.
* They say that "typically" you want to use ONE because writes will be
faster, but don't specify what "typically" means in this case.

I suppose that "typically" means "if you are not concerned about Cassandra
nodes crashes". Here's my educated guess:

1. You write to node1, updating a counter. The new value should
theoretically be 10.
2. node1 returns the success.
3. node1 should read the new value in background, but it crashes before
finishing this read. What is the current state of the counter in node1?
From the documentation, I fail to find this out.
4. You read the counter from node3 with ONE. You read 9.
5. You restart node1. I don't know what happens to the counter.

It would be great to have a clarification from Cassandra team.

Federico


On Wed, 18 Sep 2019 at 14:10, Tarun Chabarwal <ta...@gmail.com>
wrote:

> Hi
>
> I stumbled on this
> <https://docs.datastax.com/en/archived/cql/3.0/cql/ddl/ddl_counters_c.html>
> post which says use consistency level ONE with counters. I'm using
> cassandra 3 with 3 copies in one data center. I've to support consistent
> reads.
>
> Can we do LOCAL_QUORUM read/write against counters ? Is there any downside
> of using quorum with counters ?
>
> If we can't use quorum then is it possible to get consistent reads ?
>
>
> Regards
> Tarun Chabarwal
>