I am new to Riak but did make it to the helpful Riak Meet-up last week in SF
where this was discussed.  The idea here is Riak trades off consistency to
achieve greater availability and partition tolerance.  As result if two
writes to the same key happen both can complete.  Riak can reconcile the
difference later by (1) keeping only the latest version (according to Riak's
notion of time); or (2) asking the application to choose how to handle the
conflicting updates.

The above assumes the number of write replicas is one, or fewer than half
the number of nodes in the ring.  You can avoid the issue by ensuring the
write is done to a minimum quota of half the nodes.  Although I'm not sure
what response you will get if you try to commit two writes in this scenario.

There's no "lock bucket" operation - if there was you could run into
deadlock or other issues.  In the Riak model you deal with these issues in
the application rather than the infrastructure.

I guess in your example your clients with both get 100, increment to 110,
then your application will have to detect the duplicate writes.  In this
case you would be best off holding the starting value and increments, rather
than just the total.  Or current and previous values?  Anyway Riak is not
made for synchronous, transactional updates to data.

Hope that helps.

Regards,
-jad-
John Dilley
Akamai Technologies


On 9/27/10 6:28 PM, "Jan Zimmek" <[email protected]> wrote:

> hello,
> 
> i am currently evaluating riak as data-storage for out upcoming project. the
> wiki provides a lot of informations and is really good - most of my questions
> are answered, but i did not find much information about how riak handles
> concurrent client updates on the same key (i know riak uses vclocks, but i am
> not sure what this means in practise).
> 
> for example:
> 
> -------------------
> 
> having a key "X" with a given value of 100.
> 
> clientA and clientB both load "X" in parallel, increment it by 10 and store it
> back into riak.
> 
> will "X" have a value of 110, 120 or do we get something like a "concurrent
> modification"-error ?
> 
> (in my case i want riak to store the value as 120 or give me same "concurrent
> modification"-error)
> 
> does it matter if clientA and clientB are connected to the same/different
> physical riak-node ?
> 
> -------------------
> 
> does riak support some kind of lock-handling like "lock table(bucket)" /
> "select for update" as in sql or do i have to implement this in my
> application-layer ?
> 
> any help would be really appreciated.
> 
> regards
> jan zimmek
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to