5 ms·
There are a several ways to approach this. The simplest is to just take last-write-wins, which is the only option some distributed databases give you. For cases
by reiddraper 14y ago
There are a several ways to approach this. The simplest is to just take last-write-wins, which is the only option some distributed databases give you. For cases where this isn't ideal, you resolve write-conflicts in a couple ways.
One way is to write domain-specific logic that knows how
to resolve your values. For example, your models might
have some state that only happen-after another state,
so conflicts of this nature resolve to the 'later' state.
Another approach is to use data-structures or a library
designed for this, like CRDTs. Some resources below:
A comprehensive study of Convergent and Commutative Replicated Data Types
http://hal.archives-ouvertes.fr/inria-00555588/ http://hal.archives-ouvertes.fr/inria-00555588/
https://github.com/reiddraper/knockbox https://github.com/reiddraper/knockbox
https://github.com/aphyr/meangirls https://github.com/aphyr/meangirls
https://github.com/ericmoritz/crdt https://github.com/ericmoritz/crdt
https://github.com/mochi/statebox https://github.com/mochi/statebox
- stock_toaster 14y agoAre there any connector libs that provide "simple" last-write-wins out of the box?
- aphyr 14y agoIt's not hard. def merge(siblings) { sort_by(siblings) { |s| s.timestamp } }.last Or, in Knockbox/Meangirls, strategies like LWW-set. Until your clocks get out of sync.
- bonzoesc 14y agoSimple last-write-wins can be configured per-bucket, so client libs can be naïve: http://wiki.basho.com/HTTP-Set-Bucket-Properties.html http://wiki.basho.com/HTTP-Set-Bucket-Properties.html