Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra row level locking support while accessing same row by concurrent users

We are in design phase of our shopping cart application we are considering Cassandra as Inventory database. Multiple users need to be able to access same product row in Inventory DB at same time.

For example a product table containing:

productID =1000, productQuantitiy = 1

productID =2000, productQuantitiy = 5

If first user selects product 1000 and add product quantity 1 in shopping cart, other users should not be able to select this product until it gets discarded by first user (who updates product quantity as 0).

Alternatively if the first user selects 3 of product 2000, other users accessing the same product should not be able to select the same amount of this product until some is discarded by the first user (who updates product quantity as 2).

Does Cassandra provide row level locking support for this kind of scenario ?

like image 803
user2718398 Avatar asked Jul 10 '26 20:07

user2718398


1 Answers

Cassandra does not have built in support for locking yet. The Astyanax API provides recipes which are implementations for common use cases, one of which, Distributed Row Lock, is for such locking.

like image 171
Lyuben Todorov Avatar answered Jul 13 '26 13:07

Lyuben Todorov