[
https://issues.apache.org/jira/browse/CASSANDRA-8051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14508327#comment-14508327
]
Stefania edited comment on CASSANDRA-8051 at 4/23/15 2:30 AM:
--------------------------------------------------------------
*Note:*
For testing I used some log statements in StorageProxy.java and
SelectStatement.java, see attached patches.
*2.0 patch:*
Confirmed that it only works for reads, for conditional updates it cannot be
used and afaict it cannot be set from Thrift either.
Here's what happens for updates:
{code}
CONSISTENCY SERIAL;
Consistency level set to SERIAL.
insert into test (id, col, val) values (2, 1, '1') IF NOT EXISTS;
Bad Request: 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"
{code}
Same for LOCAL_SERIAL.
*2.1 patch:*
"Sets consistency level for future requests" should perhaps be changed to
"..for future conditional updates"
Trailing space just above {{def do_serial(self, parsed):}}
Same issue as in 2.0 with setting CONSISTENCY to SERIAL or LOCAL_SERIAL before
conditional updates:
{code}
cqlsh:test> CONSISTENCY LOCAL_SERIAL
Consistency level set to LOCAL_SERIAL.
cqlsh:test> insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
InvalidRequest: code=2200 [Invalid query] message="LOCAL_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""
cqlsh:test> CONSISTENCY SERIAL
Consistency level set to SERIAL.
cqlsh:test> insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
InvalidRequest: code=2200 [Invalid query] message="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""
{code}
The patch doesn't work for conditional updates:
{code}
SERIAL CONSISTENCY LOCAL_SERIAL;
insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
{code}
it will give these log messages, which are incorrect:
{code}
INFO 01:20:01 Consistency level in cas for paxos : SERIAL
INFO 01:20:01 Consistency level in cas for commit : ONE
INFO 01:20:01 Consistency level in read : QUORUM
{code}
The problem is in the python driver, in query.py
{{_set_serial_consistency_level}} forgets to actually set the value:
{code}
def _set_serial_consistency_level(self, serial_consistency_level):
acceptable = (None, ConsistencyLevel.SERIAL,
ConsistencyLevel.LOCAL_SERIAL)
if serial_consistency_level not in acceptable:
raise ValueError(
"serial_consistency_level must be either
ConsistencyLevel.SERIAL "
"or ConsistencyLevel.LOCAL_SERIAL")
{code}
python-driver-fix.txt fixes it. We need to raise a python driver ticket.
I'm not sure it it's an overkill, but given that CONSISTENCY
SERIAL/LOCAL_SERIAL causes errors to conditional updates, in both 2.0 and 2.1,
perhaps we ought to consider attaching it to SELECT statements only.
was (Author: stefania):
*Note:*
For testing I used some log statements in StorageProxy.java and
SelectStatement.java, see attached patches.
*2.0 patch:*
Confirmed that it only works for reads, for conditional updates it cannot be
used and afaict it cannot be set from Thrift either.
Here's what happens for updates:
{code}
CONSISTENCY SERIAL;
Consistency level set to SERIAL.
insert into test (id, col, val) values (2, 1, '1') IF NOT EXISTS;
Bad Request: 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"
{code}
Same for LOCAL_SERIAL.
*2.1 patch:*
"Sets consistency level for future requests" should perhaps be changed to
"..for future conditional updates"
Trailing space just above {{def do_serial(self, parsed):}}
Same issue as in 2.0 with setting CONSISTENCY to SERIAL or LOCAL_SERIAL before
conditional updates:
{code}
cqlsh:test> CONSISTENCY LOCAL_SERIAL
Consistency level set to LOCAL_SERIAL.
cqlsh:test> insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
InvalidRequest: code=2200 [Invalid query] message="LOCAL_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""
cqlsh:test> CONSISTENCY SERIAL
Consistency level set to SERIAL.
cqlsh:test> insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
InvalidRequest: code=2200 [Invalid query] message="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""
{code}
The patch doesn't work for conditional updates:
{code}
SERIAL CONSISTENCY LOCAL_SERIAL;
insert into test (id, col, val) values (1, 1, '1') IF NOT EXISTS;
{code}
it will give these log messages, which are incorrect:
{code}
INFO 01:20:01 Consistency level in cas for paxos : SERIAL
INFO 01:20:01 Consistency level in cas for commit : ONE
INFO 01:20:01 Consistency level in read : QUORUM
{code}
The problem is in the python driver, in query.py
{{_set_serial_consistency_level}} forgets to actually set the value:
{code}
def _set_serial_consistency_level(self, serial_consistency_level):
acceptable = (None, ConsistencyLevel.SERIAL,
ConsistencyLevel.LOCAL_SERIAL)
if serial_consistency_level not in acceptable:
raise ValueError(
"serial_consistency_level must be either
ConsistencyLevel.SERIAL "
"or ConsistencyLevel.LOCAL_SERIAL")
{code}
python-driver-fix.txt fixes it. We need to raise a python driver ticket.
I'm not sure it it's an overkill, but given that CONSISTENCY
SERIAL/LOCAL_SERIAL causes errors to conditional updates, in both 2.0 and 2.1,
perhaps we ought to consider attaching it to SELECT statemetns only.
> Add SERIAL and LOCAL_SERIAL consistency levels to cqlsh
> -------------------------------------------------------
>
> Key: CASSANDRA-8051
> URL: https://issues.apache.org/jira/browse/CASSANDRA-8051
> Project: Cassandra
> Issue Type: Bug
> Components: Tools
> Reporter: Nicolas Favre-Felix
> Assignee: Carl Yeksigian
> Priority: Minor
> Labels: cqlsh
> Fix For: 2.0.15
>
> Attachments: 8051-2.0.txt, 8051-2.1.txt, log-statements-2.0.txt,
> log-statements-2.1.txt, python-driver-fix.txt
>
>
> cqlsh does not support setting the serial consistency level. The default
> CL.SERIAL does not let users safely execute LWT alongside an app that runs at
> LOCAL_SERIAL, and can prevent any LWT from running when a DC is down (e.g.
> with 2 DCs, RF=3 in each.)
> Implementing this well is a bit tricky. A user setting the serial CL will
> probably not want all of their statements to have a serial CL attached, but
> only the conditional updates. At the same time it would be useful to support
> serial reads. "WITH CONSISTENCY LEVEL" used to provide this flexibility.
> I believe that it is currently impossible to run a SELECT at SERIAL or
> LOCAL_SERIAL; the only workaround seems to be to run a conditional update
> with a predicate that always resolves to False, and to rely on the CAS
> response to read the data.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)