如果在使用 QUORUM CL 时在 cassandra 集群中写入失败会发生什么? [英] What will happen if write failed in cassandra cluster when using QUORUM CL?

查看:23
本文介绍了如果在使用 QUORUM CL 时在 cassandra 集群中写入失败会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有 3 个节点,RF 为 3,并且使用 QUORUM CL.当我向集群写入数据记录时,如果一个节点成功,一个节点失败.那么整个写请求都失败了,那么success节点会怎样呢?会自动回滚吗?否则它将通过八卦传播到其他节点.最后3个节点即使原始请求失败也会有记录吗?

Suppose i have 3 nodes, the RF is 3, and using QUORUM CL. When i write a data record to the cluster, if one node succeed, one failed. So the whole write request is failed, what will happen to the succeed node? Will it be roll back automatically? or it will be propagated to other node via gossip. And finally the 3 nodes will all have the record even the original request was failed?

推荐答案

有一个 关于它的文章.TL&DR 版本:

There's an article about it. TL&DR version:

  • 查询协调器将根据 RF=3 尝试将您的写入保存在所有节点上.如果其中 2 个失败,则认为 CL=QUORUM 写入失败.
  • 接受失败写入的单个节点将回滚它.由于没有发生任何可疑事件,它会将其保存在内存表/磁盘上.
  • Cassandra 是一个最终一致的数据库,因此它在一段时间内处于不一致状态是绝对没问题的,但在将来会收敛到一致状态.
  • 下次您读取 (CL=QUORUM) 之前未能写入的密钥时,如果仍然没有足够的节点在线,您将无法读取.如果其他 2 个节点恢复正常,它们将具有读取仲裁(即使该键的第三个节点数据不同)并且您将收到以前的值,不受写入失败的影响.
  • 如果 Cassandra 检测到单个密钥的此类冲突,它会执行读取修复过程,当冲突的少数节点数据将被来自法定多数的数据覆盖时.因此,接受失败写入的节点将在下一次成功的仲裁读取时自我修复不一致的行.
  • Query coordinator will try to persist your write on all nodes according to RF=3. If 2 of them has failed, the CL=QUORUM write considered as failed.
  • A single node which accepted the failed write will not rollback it. It will persist it on memtable/disk as nothing suspicious happened.
  • Cassandra is an eventually consistent database, so it's absolutely fine for it to be in an inconsistent state for some period of time, but converging to consistent state in some future.
  • Next time you read (CL=QUORUM) the key you previously failed to write, if there's still not enough nodes online, you'll get failed read. If other 2 nodes will come back to life, they will have read quorum (even if the third node data differs for that key) and you'll receive previous value, unaffected by the failed write.
  • If Cassandra detects such a conflict for a single key, it performs read repair process, when conflicting minority nodes data will be overwritten by the data from quorum's majority. So your node, which accepted failed write, will self-heal inconsistent row on next successful quorum read.

这篇关于如果在使用 QUORUM CL 时在 cassandra 集群中写入失败会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆