You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Hiroyuki Yamada <mo...@gmail.com> on 2016/01/07 10:44:11 UTC

what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Hi,

I've been doing some POCs of lightweight transactions and
I come up with some questions, so please let me ask them to you here.

So the question is:
what consistency level should I set when using IF NOT EXIST or UPDATE IF
statements ?

I used the statements with ONE and QUORUM first, then it seems fine.
But, when I set SERIAL, it gave me the following error.

=== error message ===
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
SERIAL is not supported as conditional update commit consistency. Use ANY
if you mean "make sure it is accepted but I don't care how many replicas
commit it for non-SERIAL reads"
=== error message ===


So, I'm wondering what's SERIAL for when writing (and reading) and
what the differences are in setting ONE, QUORUM and ANY when using IF NOT
EXIST or UPDATE IF statements.

Could you give me some advises ?

Thanks,
Hiro

Re: what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Posted by Hiroyuki Yamada <mo...@gmail.com>.
Thanks DuyHan !
That's clear and helpful.
(and I realized that we need to call setSerialConsistency for SERIAL and
setConsistency for others.)

Thanks,
Hiro

On Tue, Jan 12, 2016 at 9:34 PM, DuyHai Doan <do...@gmail.com> wrote:

> There are 2 levels of consistency levels you can define on your query when
> using Lightweight Transaction:
>
> - one for the Paxos round: SERIAL or LOCAL_SERIAL (which indeed
> corresponds to QUORUM/LOCAL_QUORUM but named differently so people do not
> get confused)
>
> - one for the consistency of the mutation itself. In this case you can use
> any CL except SERIAL/LOCAL_SERIAL
>
> Setting the consistency level for Paxos is useful in the context of multi
> data centers only. SERIAL => require a majority wrt RF in all DCs.
> LOCAL_SERIAL => majority wrt RF in local DC only
>
> Hope that helps
>
>
>
> On Thu, Jan 7, 2016 at 10:44 AM, Hiroyuki Yamada <mo...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I've been doing some POCs of lightweight transactions and
>> I come up with some questions, so please let me ask them to you here.
>>
>> So the question is:
>> what consistency level should I set when using IF NOT EXIST or UPDATE IF
>> statements ?
>>
>> I used the statements with ONE and QUORUM first, then it seems fine.
>> But, when I set SERIAL, it gave me the following error.
>>
>> === error message ===
>> Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
>> SERIAL is not supported as conditional update commit consistency. Use ANY
>> if you mean "make sure it is accepted but I don't care how many replicas
>> commit it for non-SERIAL reads"
>> === error message ===
>>
>>
>> So, I'm wondering what's SERIAL for when writing (and reading) and
>> what the differences are in setting ONE, QUORUM and ANY when using IF NOT
>> EXIST or UPDATE IF statements.
>>
>> Could you give me some advises ?
>>
>> Thanks,
>> Hiro
>>
>>
>>
>>
>>
>

Re: what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Posted by DuyHai Doan <do...@gmail.com>.
There are 2 levels of consistency levels you can define on your query when
using Lightweight Transaction:

- one for the Paxos round: SERIAL or LOCAL_SERIAL (which indeed corresponds
to QUORUM/LOCAL_QUORUM but named differently so people do not get confused)

- one for the consistency of the mutation itself. In this case you can use
any CL except SERIAL/LOCAL_SERIAL

Setting the consistency level for Paxos is useful in the context of multi
data centers only. SERIAL => require a majority wrt RF in all DCs.
LOCAL_SERIAL => majority wrt RF in local DC only

Hope that helps



On Thu, Jan 7, 2016 at 10:44 AM, Hiroyuki Yamada <mo...@gmail.com> wrote:

> Hi,
>
> I've been doing some POCs of lightweight transactions and
> I come up with some questions, so please let me ask them to you here.
>
> So the question is:
> what consistency level should I set when using IF NOT EXIST or UPDATE IF
> statements ?
>
> I used the statements with ONE and QUORUM first, then it seems fine.
> But, when I set SERIAL, it gave me the following error.
>
> === error message ===
> Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
> SERIAL is not supported as conditional update commit consistency. Use ANY
> if you mean "make sure it is accepted but I don't care how many replicas
> commit it for non-SERIAL reads"
> === error message ===
>
>
> So, I'm wondering what's SERIAL for when writing (and reading) and
> what the differences are in setting ONE, QUORUM and ANY when using IF NOT
> EXIST or UPDATE IF statements.
>
> Could you give me some advises ?
>
> Thanks,
> Hiro
>
>
>
>
>

Re: what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Posted by Hiroyuki Yamada <mo...@gmail.com>.
Can anyone answer my questions ?
I think the current datastax documents including python's one don't
describe how we should set consistency with lightweight transactions
precisely.

Regards,
Hiro

On Fri, Jan 8, 2016 at 11:48 AM, Hiroyuki Yamada <mo...@gmail.com> wrote:

> Thanks Tyler.
>
> I've read the python document and it's a bit more clear than before,
> but i'm still confused at what combinations make lightweight transaction
> operations work correctly.
>
> So, let me clarify the conditions where lightweight transactions work.
>
> QUORUM conditional write -> QUORUM read => OK (meets linearizability)
> ANY conditional write -> SERIAL read =>  OK (meets linearizability)
> ONE conditional write -> SERIAL read => OK ?
> SERIAL conditional write -> ??? read => ERROR for some reasons (why?)
>
> One question is that my understanding about the top 2 conditions are
> correct ?
> And the other question is "ONE conditional write - SERIAL read" is ok ?
> Also, why SERIAL conditional write fails
> even though SERIAL conditional write with (for example) ANY read
> afterwards seems logically OK ?
>
> The following document says that it seems like we can specify SERIAL in
> writes,
> so, when should I use SERIAL in writes except conditional writes (, which
> fails) ?
> <
> https://docs.datastax.com/en/cassandra/2.0/cassandra/dml/dml_config_consistency_c.html
> >
>
>
> Thanks,
> Hiro
>
>
>
> On Fri, Jan 8, 2016 at 2:44 AM, Tyler Hobbs <ty...@datastax.com> wrote:
>
>> The python driver docs explain this pretty well, I think:
>> http://datastax.github.io/python-driver/api/cassandra/query.html#cassandra.query.Statement.serial_consistency_level
>>
>> On Thu, Jan 7, 2016 at 3:44 AM, Hiroyuki Yamada <mo...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I've been doing some POCs of lightweight transactions and
>>> I come up with some questions, so please let me ask them to you here.
>>>
>>> So the question is:
>>> what consistency level should I set when using IF NOT EXIST or UPDATE IF
>>> statements ?
>>>
>>> I used the statements with ONE and QUORUM first, then it seems fine.
>>> But, when I set SERIAL, it gave me the following error.
>>>
>>> === error message ===
>>> Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
>>> SERIAL is not supported as conditional update commit consistency. Use ANY
>>> if you mean "make sure it is accepted but I don't care how many replicas
>>> commit it for non-SERIAL reads"
>>> === error message ===
>>>
>>>
>>> So, I'm wondering what's SERIAL for when writing (and reading) and
>>> what the differences are in setting ONE, QUORUM and ANY when using IF
>>> NOT EXIST or UPDATE IF statements.
>>>
>>> Could you give me some advises ?
>>>
>>> Thanks,
>>> Hiro
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Tyler Hobbs
>> DataStax <http://datastax.com/>
>>
>
>

Re: what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Posted by Hiroyuki Yamada <mo...@gmail.com>.
Thanks Tyler.

I've read the python document and it's a bit more clear than before,
but i'm still confused at what combinations make lightweight transaction
operations work correctly.

So, let me clarify the conditions where lightweight transactions work.

QUORUM conditional write -> QUORUM read => OK (meets linearizability)
ANY conditional write -> SERIAL read =>  OK (meets linearizability)
ONE conditional write -> SERIAL read => OK ?
SERIAL conditional write -> ??? read => ERROR for some reasons (why?)

One question is that my understanding about the top 2 conditions are
correct ?
And the other question is "ONE conditional write - SERIAL read" is ok ?
Also, why SERIAL conditional write fails
even though SERIAL conditional write with (for example) ANY read afterwards
seems logically OK ?

The following document says that it seems like we can specify SERIAL in
writes,
so, when should I use SERIAL in writes except conditional writes (, which
fails) ?
<
https://docs.datastax.com/en/cassandra/2.0/cassandra/dml/dml_config_consistency_c.html
>


Thanks,
Hiro



On Fri, Jan 8, 2016 at 2:44 AM, Tyler Hobbs <ty...@datastax.com> wrote:

> The python driver docs explain this pretty well, I think:
> http://datastax.github.io/python-driver/api/cassandra/query.html#cassandra.query.Statement.serial_consistency_level
>
> On Thu, Jan 7, 2016 at 3:44 AM, Hiroyuki Yamada <mo...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I've been doing some POCs of lightweight transactions and
>> I come up with some questions, so please let me ask them to you here.
>>
>> So the question is:
>> what consistency level should I set when using IF NOT EXIST or UPDATE IF
>> statements ?
>>
>> I used the statements with ONE and QUORUM first, then it seems fine.
>> But, when I set SERIAL, it gave me the following error.
>>
>> === error message ===
>> Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
>> SERIAL is not supported as conditional update commit consistency. Use ANY
>> if you mean "make sure it is accepted but I don't care how many replicas
>> commit it for non-SERIAL reads"
>> === error message ===
>>
>>
>> So, I'm wondering what's SERIAL for when writing (and reading) and
>> what the differences are in setting ONE, QUORUM and ANY when using IF NOT
>> EXIST or UPDATE IF statements.
>>
>> Could you give me some advises ?
>>
>> Thanks,
>> Hiro
>>
>>
>>
>>
>>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Re: what consistency level should I set when using IF NOT EXIST or UPDATE IF statements ?

Posted by Tyler Hobbs <ty...@datastax.com>.
The python driver docs explain this pretty well, I think:
http://datastax.github.io/python-driver/api/cassandra/query.html#cassandra.query.Statement.serial_consistency_level

On Thu, Jan 7, 2016 at 3:44 AM, Hiroyuki Yamada <mo...@gmail.com> wrote:

> Hi,
>
> I've been doing some POCs of lightweight transactions and
> I come up with some questions, so please let me ask them to you here.
>
> So the question is:
> what consistency level should I set when using IF NOT EXIST or UPDATE IF
> statements ?
>
> I used the statements with ONE and QUORUM first, then it seems fine.
> But, when I set SERIAL, it gave me the following error.
>
> === error message ===
> Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
> SERIAL is not supported as conditional update commit consistency. Use ANY
> if you mean "make sure it is accepted but I don't care how many replicas
> commit it for non-SERIAL reads"
> === error message ===
>
>
> So, I'm wondering what's SERIAL for when writing (and reading) and
> what the differences are in setting ONE, QUORUM and ANY when using IF NOT
> EXIST or UPDATE IF statements.
>
> Could you give me some advises ?
>
> Thanks,
> Hiro
>
>
>
>
>


-- 
Tyler Hobbs
DataStax <http://datastax.com/>