News for hackers. Stuff that matters.

bogdando

Re:Is Redlock Safe? Reply to Redlock Analysis on Wednesday February 10, 2016 @02:23AM (#11071226)
This pseudo code for random fence tokens should work as well safe as Martin's scenario with incremental IDs in the original article:

try

  token=lock.aquire

  val=raw(shared, key, token)

  do_things

  awar(shared, key, val, token)
except

  fail("Can't do!")
finally

  lock.release
Where a shared object has: 1) a key to store a value being changed in the critical section; 2) a currlock to store a random fence token associated with a lock. The raw reads the shared key's value after the currlock was written to the shared object. The awar does an atomic write of the value to the key, only if the currlock has an expected token (i.e. is unchanged).

When things go wrong, the do_things may be executed more than once, in parallel, but the key is safe and guaranteed to have no lost updates to its value.

Re:How to do distributed locking on Tuesday February 09, 2016 @04:12PM (#11068807)
> In a reasonably well-behaved datacenter environment, the timing assumptions will be satisfied most of the time – this is known as a partially synchronous system [12]. But is that good enough?

Please consider this answer [0] (which I personally understood as - YES, real systems are always partial sync): "Asynchronous systems have no fixed upper bounds. In practice, systems tend to exhibit partial synchrony, which is described as one of two models by Dwork and Lynch in Consensus in the Presence of Partial Synchrony. [1]"

[0] http://bravenewgeek.com/category/distributed-systems-2/

[1] http://groups.csail.mit.edu/tds/papers/Lynch/jacm88.pdf