本文介绍了在法定人数的一致性级别上读取Cassandra中的Operation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读此帖子关于Cassandra中的读取操作和一致性级别.根据这篇文章:

例如,在复制因子为3,读取一致性级别为QUORUM的群集中,将联系给定行的3个副本中的2个副本,以满足读取请求.假设联系的副本具有不同的行版本,则具有最新版本的副本将返回请求的数据.在后台,检查第三个副本与前两个副本的一致性,如果需要,最新的副本将向过期的副本发出写操作.

因此,即使Quorum具有一致性级别,也不能保证您不会过时.根据上一段,如果第三个副本具有最新时间戳,则协调器已经返回了所查询的两个副本的最新时间戳.但这不是最新的,因为第三个副本具有最新的时间戳.

解决方案

QUORUM CL 读操作不能保证数据的一致性.保证一致性的是以下条件

将保证数据一致性所需的最小W + R转换为

就像帖子中所说的那样,如果您的复制因子为3,并且您用CL1编写的内容肯定是1个节点有新信息,而其他2个节点可能有旧信息.要求cassandra读取CL QUORUM,您可能会从其他2个节点中检索数据(旧数据),并将信息返回给客户端.但是,由于协调器已将读取请求发送到所有节点(但仅等待2个,然后将响应发送回客户端),因此他将找出哪个节点具有最新鲜的信息并更新其他节点.

其他情况下,在RF3情况下,如果在Quorum中写入数据,则至少2个节点将具有新鲜信息-使用CL QUORUM进行读取将调用3个节点中的2个,在这种情况下,两个节点中的至少一个有新鲜的信息.

I am reading this post on read operations and consistency level in Cassandra. According to this post:

For example, in a cluster with a replication factor of 3, and a read consistency level of QUORUM, 2 of the 3 replicas for the given row are contacted to fulfill the read request. Supposing the contacted replicas had different versions of the row, the replica with the most recent version would return the requested data. In the background, the third replica is checked for consistency with the first two, and if needed, the most recent replica issues a write to the out-of-date replicas.

So even with consistency level of Quorum, it is not guaranteed that you don't get a stale read.According to the above paragraph, if the third replica has the latest timestamp, the co-coordinator has already returned the latest timestamp of the two replicas it inquired. But it is not the latest since third replica has the latest timestamp.

解决方案

The QUORUM CL read does not guarantee the consistency of your data. What guarantees consistency is the following disequation

Translating the minimum W+R needed to guarantee data-consistency is

Like said in the post, if you have a Replication Factor of 3 and you wrote with CL1 surely 1 node have fresh information while other 2 might have old information. Asking cassandra a CL QUORUM read you might retrieve data from the other 2 nodes (old data), and get information back to the client. But since the coordinator sent the read request to all nodes (but waited only for 2 before sending back the response to the client) he will find out which node has the most fresh information and update other nodes.

Other, in a RF3 situation, if you write data in Quorum at least 2 nodes will have fresh information -- performing a read with CL QUORUM will invoke 2 of the 3 nodes, in this situation at least one of the two nodes have the fresh information.

这篇关于在法定人数的一致性级别上读取Cassandra中的Operation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:40