sabato 23 novembre 2013

Transaction in Cassandra (or other NOSQL repositories)

Transaction in Cassandra 
(or other NOSQL repositories)


Yesterday i began to work with Cassandra system, but i found soon a important constraint: is not possible define transactions in this system.
Cassandra is distributed system without a central load balancer: this is a great idea cause it removes additional network latency and encreases fail over problems associated with load balancer.  
The basic problem cause is not possible to define transaction is in a distributed system is not possible to know the right and unique sequence of transactional events on a specific  set of rows.
It is really impossible to add transaction in this system?
there is a way for making it: all clients connecting to Cassandra know all the nodes bound to cluster. When a client create a transaction , the cluster creates a "agglomerate" containing a group of elements as (columnset, rowid): a kind of partial transaction log. This info is spammed out to the other clients. A agglomerate can belong just a unique Cassandra node of cluster. In this way a specific transaction is passing just for a single node of cluster and the node working on it can order the concurrent events about it.When a client open a new connection with a node receives all the agglomerates of the specific node and when the agglomerate is no more used ... it is removed ether in cluster node either in all clients.  All this synchronization operations are concurrent so the total time for doing them are about similar to one of them.
if a client tries to send a transaction to wrong node , this node send a special info telling the the client must search the right node.
Another way to reduce synchronization time is introducing transactional logic.
In this second method a transaction is not defined as a set of indipendent basic operations instead it defines the operational logic in which atomic data change. 
it this way a transactional logic is defined with a unique identifier before to open/close transaction itself. Every transactional logic is associated with a unique node of cluster and the cluster know which node must process that transaction.  A special transaction logic analisys could help to understand if different transactional logics can work on same data.