On September 19, 2013 10:12:06 AM Markus Doppelbauer wrote:
> Hi Alex,
>  
> Thanks a lot for your answer.
> Very often (we upgrade an application from BerkeleyDB to RIAK).
>  
> E.g.: A new key should be be the largest key + 1. Is there an other
> trick to workaround this problem?
>  
> Thanks,
> Markus
>  
Hi Markus,

Because Riak is an eventually consistent system, it is very hard/next to 
impossible to guarantee this property using Riak alone.  For instance, if you 
have a cluster split, then several inserts you will end up with multiple 
records with the same id.  This occusrs since both sides of the cluster will 
only see its new keys, and believe that the ids are all unique.

Instead, you could use something like Twitter's snowflake (available here: 
https://github.com/twitter/snowflake ) (if you don't want java, there are 
various re-implementations of it around).  Snowflake will generate ids that 
are generally incrementing, but will also leave gaps.  You can run multiple 
instances (safely) to get redundancy or capacity.  Snowflake works without 
having to synchronize its state amongst several servers, so it would continue 
to work in the face of cluster splits.
-- 
Matthew

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to