问题描述
我试图在ZooKeeper的帮助下实现Cassandra的事务系统。因为我不认为我有足够的数据库实施经验,我想知道我的想法是否会原则上工作,还是有任何重大缺陷。
I am trying to implement a transaction system for Cassandra with the help of ZooKeeper. Since I don't think I have enough experience in database implementation, I would like to know if my idea would work in principle, or is there any major flaw.
在这里是高级描述的步骤:
Here is the high level description of the steps:
- 标识要编辑的所有行(键)和列。让键为[K0..Kn]
- 对所有涉及的行应用写锁定(锁是内存中的Zookeeper实现)
- 旧的值以分隔由Cassandra唯一标识的位置:[K'0..K'n]
- 存储[K'0..K'n]和映射
- 继续将更新应用到数据
- 删除ZooKeeper中的条目 / li>
- 解锁行
- 在维护线程上删除[K'0..K'n]的条目(cassandra删除使用时间戳, K'0..K'n可以重新用于具有较新时间戳的另一笔交易)
- identify all the rows(keys) and columns to be edited. Let the keys be [K0..Kn]
- apply write lock on all the rows involved (locks are in-memory Zookeeper implementation)
- copy the old values to separate locations in Cassandra which are uniquely identified by key: [K'0..K'n]
- store [K'0..K'n] and the mapping of them to [K0..Kn] in ZooKeeper using persistent mode
- go ahead apply the update to the data
- delete the entries in ZooKeeper
- unlock the rows
- delete the entries of [K'0..K'n] lazily on a maintenance thread (cassandra deletion uses timestamp, so K'0..K'n can be reused for another transaction with a newer time stamp)
说明:
- 如果事务在步骤1-4失败,没有应用更改,我可以中止事务并删除存储在zookeeper和备份在cassandra
- 如果在步骤5中交易失败,则使用步骤3中保存的信息来回滚任何更改。
- 服务器发生故障/崩溃/偷窃通过清洁人,在重新启动服务任何请求之前,我检查是否有任何密钥持久存储在zookeeper从步骤4,如果是,我将使用这些键来获取备份的数据存储步骤3,并将这些数据放在他们所在的地方,从而回滚任何失败的交易。
如果某些服务器与集群分区,则会发生这种情况。我在这方面没有经验,我的计划是否工作?
One of my concern is what would happen if some of the servers are partitioned from the cluster. I have no experience in this area, does my scheme work at all? and does it work if partition happens?
推荐答案
您应该查看Cages:
You should look into Cages: http://ria101.wordpress.com/2010/05/12/locking-and-transactions-over-cassandra-using-cages/
这篇关于Cassandra与ZooKeeper交易 - 这工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!