Indexing conflicts (feature)

Erik Søe Sørensen ess at trifork.com
Thu Jul 4 08:12:43 EDT 2013


Hi all -
I'm not sure whether this has been discussed here before, but I've at 
times felt that Riak - while having a great way of supporting resolution 
of write conflicts - is missing a good way of *detecting* such conflicts.
(Unless of course some feature has been added which I have missed...)
And recently, when trying to reason about whether our Riak-based 
algorithm gave the guarantees it was supposed to, and what to do about 
it when it didn't, one of the conclusions was "either this goes well, or 
else we get a conflict, in which case all is well if we find and handle 
that conflict in a timely manner".

Now, I'm as much for periodic jobs reviewing nontrivial parts of the 
database as the next man (and also fudge factors such as "upper bound on 
consistency delay"), but I think we can do better. :-)

Thus, I give to you, for your consideration and discussion, a mechanism 
for indexing conflicts in 2i as they arise:

     https://github.com/trifork/riak_kv/tree/sibling_index

I think 2i is a quite appropriate vehicle for this. The implementation 
doesn't have much rocket science in it, either. As for the special names 
involved (and the extent to which the mechanism should be configurable), 
I'll leave that to the naming (and configurability) experts.
As far as I know, the code would also handle conflicts created at 
replication time.

Enough talk - demo time:

    # First, setup bucket to support conflicts:
    $ curl -XPUT -H'content-type: application/json' -d'{"props":
    {"allow_mult": true}}' http://localhost:8098/buckets/somebucket/props

    # Create an object, marking it as something we'd like to monitor for
    siblings:
    $ curl -XPUT -d'Value 1' -H'X-Riak-Meta-X-Index-Siblings: true'
    http://localhost:8098/buckets/somebucket/keys/thekey

    # Then create a conflict:
    $ curl -XPUT -d'Value 2'
    http://localhost:8098/buckets/somebucket/keys/thekey

    # Are there any conflicts?
    $ curl -XGET
    http://localhost:8098/buckets/somebucket/index/x_riak_siblings_int/0/999999
    {"keys":["thekey"]}

    # The value of the index is the number of siblings.
    $ curl -XGET
    http://localhost:8098/buckets/somebucket/index/x_riak_siblings_int/2/2
    {"keys":["thekey"]}


What do you think?

Regards,
Erik Søe Sørensen
-- 
Mobile: + 45 26 36 17 55 | Skype: eriksoesorensen | Twitter: @eriksoe
Trifork A/S  |  Margrethepladsen 4  |  DK-8000 Aarhus C | 
www.trifork.com <http://www.trifork.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20130704/81965fac/attachment.html>


More information about the riak-users mailing list