how to integrate cassandra with zookeeper to support transactions

10.4k Views Asked by At

I have a Cassandra cluster and Zookeeper server installed. Now I want to support transactions in cassandra using zookeeper. How do i do that.

Zookeeper creates znodes to perform read and write operations and data to and fro goes through znodes in Zookeeper. I want to know that how to support rollback and commit feature in cassandra using Zookeeper. Is there any way by which we can specify cassandra configurations in zookeeper or zookeeper configurations in cassandra.

I know cassandra and zookeeper individually how data is read and written but I dont know how to integrate both of them using Java.

how can we do transactions in Cassandra using Zookeeper.

Thanks.

4

There are 4 best solutions below

0
On

Well, I'm not an exepert at this (far from it actually) but the way I see it, either you deploy some middleware made by yourself, in order to guarantee the specific properties you are looking for or you can just have Cassandra write data to auxilliary files and then copy them through the file system, since the copy function in Java works as an atomic operation.

I don't know anything about the size of the data files you are considering so I don't really know if it is doable, however there might be a way to use this property through smaller bits of information and then combining them as a whole.

Just my 2 cents...

0
On

I have a Cassandra cluster and Zookeeper server installed. Now I want to support transactions in cassandra using zookeeper. How do i do that.

With great difficulty. Cassandra does not work well as a transactional system. Writes to multiple rows are not atomic, there is no way to rollback writes if some writes fail, and there is no way to ensure readers read a consistent view when reading.

I want to know that how to support rollback and commit feature in cassandra using Zookeeper.

Zookeeper won't help you with this, especially the commit feature. You may be able to write enough information to zookeeper to roll back in case of failure, but if you are doing that, you might as well store the rollback info in cassandra.

Zookeeper and Cassandra work well together when you use Zookeeper as a locking service. Look at the Cages library. Use zookeeper to co-ordinate read/writes to cassandra.

Trying to use cassandra as a transactional system with atomic commits to multiple rows and rollbacks is going to be very frustrating.

0
On

There are ways you can use to implement transactions in Cassandra without ZooKeeper.

Cassandra itself has a feature called Lightweight transactions which provides per key linearizability and compare-and-set. With such primitives you can implement serializable transactions on the application level by youself.

Please see the Visualization of serializable cross shard client-side transactions post for for details and step-by-step visualization.

The variants of this approach are used in Google's Percolator system and in CockroachDB.

By the way, if you're fine with Read Committed isolation level then it makes sense to take a look on the RAMP transactions paper by Peter Bailis.

0
On

There is a BATCH feature for Cassandra's CQL3 (Cassandra 1.2 is the formal version that released CQL3), which allegedly can atomically apply all the updates in the BATCH as one unit all-or-nothing.

This does not mean you can rollback a successfully executed BATCH as an RDBMS could do, that would have to be manually done.

Depending on the consistency and preferences you provide to the BATCH statement, guarantees of atomicity of the updates can be increased or decreased to some degree with the UNLOGGED option.

http://www.datastax.com/docs/1.2/cql_cli/cql/BATCH