本文介绍了即使不能满足一致性,Cassandra是否写入一个节点(它是否为up)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下来自Cassandra文档的声明是我怀疑的原因。

The below statement from Cassandra documentation is the reason for my doubt.

例如,如果使用QUORUM的写一致性级别,复制因子为3,Cassandra将复制对集群中所有节点的写入,并等待来自两个节点的确认。如果写入在其中一个节点上失败,但在另一个节点上成功,Cassandra报告无法复制该节点上的写入。但是,在其他节点上成功的复制写入操作不会自动回滚。

For example, if using a write consistency level of QUORUM with a replication factor of 3, Cassandra will replicate the write to all nodes in the cluster and wait for acknowledgement from two nodes. If the write fails on one of the nodes but succeeds on the other, Cassandra reports a failure to replicate the write on that node. However, the replicated write that succeeds on the other node is not automatically rolled back.

参考:

即使不能满足Consistency,Cassandra也会写入一个节点(上升)​​。

So does Cassandra write to a node(which is up) even if Consistency cannot be met ?

推荐答案

我得到了。 Cassandra甚至不会尝试写入,如果它知道不能满足一致性。如果一致性可以满足,但是没有足够的副本来满足复制因素,Cassandra将写入当前可用的副本并给出成功消息。以后当副本重新启动时,它将写入其他副本。

I got it. Cassandra will not even attempt to write if it knows that consistency cannot be met. If consistency CAN be met, but does not have enough replicas to satisfy replication factor, then Cassandra would write to currently available replicas and gives a success message. Later when the replica is up again, it will write to other replica.

如果复制因子为3,则3个节点中有1个失败,则如果我使用Consistency为2写入,则写入将成功。但是如果复制因子是2,并且2个节点中有1个失败,那么如果我使用一致性2写入,Cassandra甚至不会写入可用的单个节点。

For e.g. If Replication factor is 3 , 1 of 3 nodes are down, then if I write with a Consistency of 2, the write will succeed. But if Replication factor is 2 and 1 of 2 nodes are down , then if I write with a Consistency of 2, Cassandra will not even write to that single node which is available.

文档中提到的是一种情况,即写入在启动时可以满足一致性。但在中间,一个节点下降,无法完成写入,而写入成功在其他节点。由于不能满足一致性,客户端将收到失败消息。写入单个节点的记录将在节点修复或压缩过程中删除。

What is mentioned in the documentation is a case where while write was initiated when the consistency can be met. But in between, one node went down and couldn't complete the write, whereas write succeeded in other node. Since consistency cannot be met, client would get a failure message. The record which was written to a single node would be removed later during node repair or compaction.

这篇关于即使不能满足一致性,Cassandra是否写入一个节点(它是否为up)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 23:43