Cassandra - Select without replication

余生长醉 提交于 2019-12-05 11:55:46

Every copy of the data, including the original, is a replica. Replication factor is not a count of additional copies, it is the total number of copies. You need RF >= 1.

I'm rather surprised that it allows RF == 0. With no replicas available, there's nothing to read. However, a comment on CASSANDRA-4486 indicates that this is intentionally allowed, but for special purposes:

. . . the point is that it's legitimate to set up a zero-replication keyspace (this is common when adding a new datacenter) and change it later. In the meantime, it's correct to reject writes to it.

And the write does not result in an error probably due to hinted handoff as mentioned in the descriptions for consistency levels, for ANY:

A write must be written to at least one node. If all replica nodes for the given partition key are down, the write can still succeed after a hinted handoff has been written. If all replica nodes are down at write time, an ANY write is not readable until the replica nodes for that partition have recovered.

So, if you want confirmation that your write was persisted to at least one node and not rely on the hinted handoff (which can expire), then write with consistency level ONE and not ANY.

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