Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra mutual exclusion locking (synchronization)

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 SELECT ... 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.

like image 653
Daimon Avatar asked Jan 17 '11 21:01

Daimon


3 Answers

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

like image 95
Schildmeijer Avatar answered Oct 14 '22 04:10

Schildmeijer


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.

like image 2
Pranab Avatar answered Oct 14 '22 05:10

Pranab


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

like image 2
Praveen Avatar answered Oct 14 '22 05:10

Praveen