Reputation: 10667
We have a use case where we need to write/update two tables with transaction support. This is required as both tables are related so they can't be out of sync. We have also discussed about merging two tables but that doesn't look feasible.
AFAIK, Cassandra doesn't provide transaction support out of box. Are there any technique/library available to do that?
We are also evaluating Couchbase for this. Do you think couchbase will be a better option than Cassandra.
Upvotes: 1
Views: 1353
Reputation: 1928
Cassandra supports per-key linearizability and compare-and-set (CAS). It's enough for implementing transactions on the client side.
Percolator's transactions provides serializable isolation level. They are quite known in the industry and are in use in the Amazon's DynamoDB transaction library, in the CockroachDB database and in the Google's Pecolator system itself. A step-by-step visualization of the Percolator's transactions may help you to understand them.
If you expect contention and can deal with Read Committed isolation level then RAMP transactions by Peter Bailis may suit you. I also created a step-by-step RAMP visualization which may be useful for understanding.
The third approach is to use compensating transactions also known as the saga pattern. It was described in the late 80s in the Sagas paper but became more relevant with the rise of distributed systems. Please see the Applying the Saga Pattern talk for inspiration.
Upvotes: 3
Reputation: 4845
In Couchbase you very possible could combine what would of been in three different tables in a RDMBS into one JSON document and therefor not need transactions. Without knowing your application, I cannot know what a good JSON document model should be for this though. Comparing Relational schemas to NoSQL schemas is apples to oranges.
On a related note, Couchbase is strongly consistent when you write a single object. Your read/write always goes to the same active vBucket(i.e. shard).
Upvotes: 2
Reputation: 617
Cassandra supports transaction only within a single partition (in a single table). Have a look on batch queries that might help you a little bit: http://docs.datastax.com/en/cql/3.1/cql/cql_reference/batch_r.html
Upvotes: 2