Cassandra mutual exclusion lock (synchronization)

Is there any client synchronization using cassandra built-in functions?

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

In the DBMS, I can lock the entire table or prepare a special table for synchronization purposes and use SELECT ... FOR UPDATE on it.

Can I achieve this with Cassandra without any third-party applications? If not the best way to do this? Preferred languages ​​are Java and Python.

+8
synchronization locking cassandra mutual-exclusion
source share
4 answers

It is not possible to block the whole (or a subset of a) familiy column without third-party libraries like Apache ZooKeeper .

I would probably start looking at Domic Williams cages before starting to roll my own locking mechanism.

+8
source share

If you update a single row in a column family, it is atomic. But it will not work, how to choose to upgrade. You should probably go back to your data model with more denormalization, so you don't need to worry about synchronization.

+2
source share

Since C * provides row-level atomicity, why not use the Lamport Bakery Algorithm . I also found an incomplete page on the C * wiki.

https://github.com/jakedouglas/cassandra_lock

+2
source share

I also looked for a way to do synchronization with cassandra, but as far as I know, it does not provide mechanisms for implementing mutexes.

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

So, you can use memcached to implement mutexes for synchronizing and reading / writing data with the quorum consistency level in cassandra to make sure that the last record always comes back when reading.

Does anyone know about implementing a mutex with memcached?

0
source share

Source: https://habr.com/ru/post/651181/


All Articles