Skip to content

Instantly share code, notes, and snippets.

@PharkMillups
Created May 14, 2010 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PharkMillups/401497 to your computer and use it in GitHub Desktop.
Save PharkMillups/401497 to your computer and use it in GitHub Desktop.
danlarkin # I asked about this last night, but I'll try again now in a slightly different way,
I've got many threads (on different machines) between which I want to coordinate state
I thought about using riak, but I can't find any user-facing atomic operations
like a CaS or forcing creation of siblings, even if the writes happen discretely, or something
seancribbs # danlarkin: no, Riak is eventually consistent. If you want to consider an operation atomic, it is only within the context of a single request (and not within the storage mechanism)
requests do not lock anything either, so you may still end up with race-conditions
danlarkin # I would be okay with commutativity
so eventually consistent is ok
seancribbs # commutativity?
danlarkin # the insertion order doesn't matter, just that nothing is overwritten
seancribbs # ah yes. you can bubble up update conflicts to the application
which can decide how to resolve/merge them
danlarkin # but conflicts only occur when writes happen concurrently, not discretely, right?
seancribbs # or when there is a partition, i.e. network failure
danlarkin # so one thread can still end up overwriting what another thread wrote
seancribbs # you can simulate a conflict by storing an object multiple times with the same parent vclock
no, we won't overwrite. siblings will be created whether you choose to see those siblings is up to you
danlarkin # so.. two threads, first one reads the document, makes a change, and writes it back -- but inbetween the read and write the other thread reads _and_ writes... would those changes be overwritten by the first thread's last-write-winning?
seancribbs # that's what I'm saying, it won't be. if you set "allow_mult" to true on the bucket, both versions will be written. then in your next read, you will be shown both versions
danlarkin # I see, I misunderstood then exxxcellent
seancribbs # if allow_mult is false (the default), only the latest version will be shown (even if siblings exist)
danlarkin # so how does riak know there's a "conflict", the client sends the vclock from its read back when it writes?
seancribbs # yes
danlarkin # perfect thanks sean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment