How do I set CONSISTENCY to SERIAL in cqlsh?

眉间皱痕 提交于 2021-02-10 14:23:59

问题


I am trying to experiment with lightweight transactions in Cassandra by using SERIAL consistency. However, trying to set the consistency level in cqlsh results in an error:

cqlsh:learning> CONSISTENCY SERIAL;
Improper CONSISTENCY command.

The WITH CONSISTENCY statement has been removed from CQL and so I cannot use that. Is there a way to enable serial consistency from cqlsh? Or do I have to do it using a driver?


回答1:


The CONSISTENCY command should still work in cqlsh. But valid values for this setting are:

  • ANY
  • ONE
  • TWO
  • THREE
  • QUORUM
  • ALL
  • LOCAL_QUORUM
  • EACH_QUORUM

SERIAL is not in that list, hence the error you are seeing. There is an open Jira ticket to address this: CASSANDRA-8051

This appears to be a consistency level that has some restrictions around it, thus making this difficult to implement. The Consistency Level descriptions indicate that:

You cannot configure this level as a normal consistency level, configured at the driver level using the consistency level field.

The Java Driver apparently has a specific method to set this consistency level:

The serial consistency level of the query, set with Statement.setSerialConsistencyLevel(), is similar to the consistency level, but only used in queries that have conditional updates. That is, it is only used in queries that have the equivalent of the IF condition in CQL.



来源:https://stackoverflow.com/questions/28591874/how-do-i-set-consistency-to-serial-in-cqlsh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!