如果我将正常一致性级别设置为条件写入 (LWT) 会发生什么情况?

What will happen if I set normal consistency level to conditional write (LWT)?

我有 6 个节点集群,复制因子为 3。我使用正常一致性级别作为 QUORUM,串行一致性级别作为 SERIAL。

我有条件写入查询 (IF EXIST)。如果我使用如下所示的 datastax java 驱动程序将正常和串行设置为此语句,将会发生什么。

//preparedStatement has a conditional query.
BoundStatement boundStatement = new BoundStatement(preparedStatement);
boundStatement.setSerialConsistencyLevel(ConsistencyLevel.SERIAL);
//is this required??
boundStatement.setConsistencyLevel(ConsistencyLevel.QUORUM);

我的查询:

  1. 正常一致性 QUORUM 会被忽略还是会被考虑在内?
  2. 在这种情况下我应该只设置串行一致性级别吗?

我在下面提到了 link 但它并没有解释太多 https://docs.datastax.com/en/cassandra/3.x/cassandra/dml/dmlConfigSerialConsistency.html

The learn phase, which defines what read operations will be guaranteed to complete immediately if lightweight writes are occurring uses a normal consistency level.

请简单说明。

串行一致性级别仅用于轻量级事务的Paxos阶段。如果该阶段成功,那么实际的突变(读取或写入)将使用指定的 "normal" 一致性级别发生。

所以回答你的问题:

Will the normal consistency QUORUM will be ignored OR it will be taken into account ?

如果轻量事务成功并进行变异,会考虑

Should I set only serial consistency level in this case ?

每个语句都有一个一致性级别。如果您未在语句级别指定任何内容,the defaults defined at cluster level apply.