counter crdt in riak

David Byron dbyron at dbyron.com
Tue Oct 20 23:56:52 EDT 2015


Apologies if this is basic question, or one that's already been 
answered.  I've done a fair amount of digging (e.g. 
http://thread.gmane.org/gmane.comp.db.riak.user/12808/focus=12816), but 
I'm still confused about the documentation regarding conflict resolution 
for riak's crdt counter.  Specifically this: 
https://github.com/basho/basho_docs/blame/riak/2.1.1/source/languages/en/riak/theory/concepts/crdts.md#L238 
(using the blame view to get a line number reference in markdown), which 
says:

"Counters | Each actor keeps an independent count for increments and 
decrements; upon merge, the pairwise maximum of the counts for each 
actor will win (e.g. if one count for an actor holds 172 and the other 
holds 173, 173 will win upon merge)"

This makes it sound to me like an increment from one of the actors gets 
dropped.  Fingers crossed this isn't actually what happens.

I think this is saying the same thing that the cdrt paper (section 3.1.2 
State-based increment-only Counter (G-Counter) of 
https://hal.inria.fr/file/index/docid/555588/filename/techreport.pdf) 
says -- that increments that happen during a partition eventually 
resolve correctly.  I could use a more step-by-step illustration though 
-- pairwise maximum of the counts for each actor is a little dense.

Apologies for ugly formatting, but an example like this would make more 
sense to me.

- actor a increments counter
   a {a: 1}                   b {}

- actor b increments counter
   a {a: 1}                   b {b: 1}

- a merges b's info
   a {a: 1, b: 1}             b {b: 1}

- b merges a's info
   a:{a: 1, b: 1}             b {a: 1, b: 1}

so eventually this all resolves such that a and b both increment the 
counter by 2, right?  Is this how riak's crdt counter works?  If so I'll 
breathe a sigh of relief and make a pull request against the docs if you 
like.

Thanks much for your help.

-DB




More information about the riak-users mailing list