cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jaydeep Chovatia <chovatia.jayd...@gmail.com>
Subject Re: Lightweight tx is good enough to handle counter?
Date Fri, 23 Sep 2016 18:19:52 GMT
Ok.  But I am trying to understand a scenario under which this mis-match
can occur with light-weight tx.

On Fri, Sep 23, 2016 at 11:14 AM, DuyHai Doan <doanduyhai@gmail.com> wrote:

> Lightweight transaction is not available for counters, for the simple
> reason that counters are not idempotent
>
> On Fri, Sep 23, 2016 at 8:10 PM, Jaydeep Chovatia <
> chovatia.jaydeep@gmail.com> wrote:
>
>> We have a following table:
>>
>> create table mytable {
>>
>> id int,
>> count int static,
>> rec_id int,
>> primary key (id, rec_id)
>>
>> };
>>
>> The count in the table represents how many records (rec_id clustering
>> columns) exists. So when we add new a new record we do it following way:
>>
>> UNLOGGED BATCH
>> insert into mytable (id, rec_id) values (<id>, <rec_id>);
>> update mytable set count = <read_count> + 1 where id = <id> if count
=
>> <read_count>; //light-weight transaction
>> APPLY BATCH
>>
>> Then we do following read query as QUORUM:
>>
>> select count, rec_id from mytable where id = <id>;
>>
>> Here we expect count to exactly match number of rows (number of
>> clustering rec_id) returned. But under a stress we have observed that they
>> do not match sometimes.
>>
>> Is this expected?
>>
>> Thanks,
>> Jaydeep
>>
>
>

Mime
View raw message