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

早过忘川 提交于 2019-12-14 00:23:55

问题


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 ?


回答1:


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.




回答2:


What you want is atomicity, Cassandra can syncronize with 1000 users, however it uses the timestamp to sincronize value in each column. You can use 'all' on consitence level for write and read, thereby to send and request the informations in all nodes, but maybe you can lost availability.



来源:https://stackoverflow.com/questions/18446435/cassandra-row-level-locking-support-while-accessing-same-row-by-concurrent-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!