开发者

Cassandra mutual exclusion locking (synchronization)

开发者 https://www.devze.com 2023-02-05 00:08 出处:网络
Is there anyway to synchronise client using cassandra built in functions? I need to perform some operations and those operations need to be synchronized with all other clients (mutual exclusion).

Is there anyway to synchronise client using cassandra built in functions?

I need to perform some operations and those operations need to be synchronized with all other clients (mutual exclusion).

In RDBMS I can lock entire table or prepare special table for synchronization purposes and use S开发者_开发百科ELECT ... FOR UPDATE on it.

Can I achive this with Cassandra without any third party apps? If not what's the best way to do that? Preferable languages are Java and Python.


Its not possible to lock an entire (or a subset of a) column familiy without third party libraries like Apache ZooKeeper.

I would probably start looking at Domic Williams cages before start rolling my own distributed locking mechanism


If you are updating one row in a column family, it is atomic. But it won't work like select for update. You should probably revisit your data model with more denormalization in mind, so that you won't need to worry about synchronization.


Because C* provides row level atomicity why not use Lamport's Bakery Algorithm. I found an incomplete page on C* wiki too.

https://github.com/jakedouglas/cassandra_lock


I was also looking way to make syncronization with cassandra, but as far as I know it does not provide mechanisms to implement mutexes.

However, memcached has atomic cas (check and set) operation, which can be used to implement mutex. It has also python and java clients.

So you could use memcached to implement mutexes for syncronization and does read/write data with quorum consistency level in cassandra to make sure that latest write is always returned on when reading.

Has anyone experience about implementing mutex with memcached?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号