TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Distributed Locks Are Dead; Long Live Distributed Locks

110 pointsby cangenceralmost 6 years ago

6 comments

mjbalmost 6 years ago
This is good work, and the lock semantics and fencing token (epoch) make a lot of sense. I can&#x27;t help but think that implementing java.util.concurrent.locks.Lock will turn out to be a liability. The problem here is that the code looks like a Java lock, but the semantics are entirely different with regards to failure. Specifically:<p>&gt; While we’re on this subject, the same logic applies even to the primary FencedLock.lock() call: at the very next line of code in your program, you may no longer be holding the lock.<p>That&#x27;s not, in most programmer&#x27;s experience, how locks work. This behavior is necessary (at some level) to deal with partial failures and stalls of clients, but means that if you use this like Lock your code will be very wrong.<p>&gt; Note the key message here: all external services must participate in the fencing-token protocol, with guaranteed linearizability, for the whole setup to uphold its invariants.<p>So this isn&#x27;t really like a Java lock at all, and instead is a nice convenient way to build part of an epoch&#x2F;view change implementation. That&#x27;s useful, but in my mind the API they chose will reduce the likelihood that non-experts will use this correctly.
roro159almost 6 years ago
I think it&#x27;s worth to add a few previous discussions about distributed locks.<p>Redlock is a distributed lock using Redis: <a href="https:&#x2F;&#x2F;redis.io&#x2F;topics&#x2F;distlock" rel="nofollow">https:&#x2F;&#x2F;redis.io&#x2F;topics&#x2F;distlock</a><p>Martin Kleppmann criticized Redlock and mentioned the fencing solution: <a href="http:&#x2F;&#x2F;martin.kleppmann.com&#x2F;2016&#x2F;02&#x2F;08&#x2F;how-to-do-distributed-locking.html" rel="nofollow">http:&#x2F;&#x2F;martin.kleppmann.com&#x2F;2016&#x2F;02&#x2F;08&#x2F;how-to-do-distributed...</a><p>Antirez disagrees with the analysis and the HN post has a good discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11065933" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11065933</a>
sriram_malharalmost 6 years ago
More accurately, these are leases, not locks in the traditional sense. The lease expires when the corresponding client session ends, which is detected by the absence of a heartbeat from the client.
评论 #20107412 未加载
评论 #20107623 未加载
评论 #20109873 未加载
评论 #20110504 未加载
cangenceralmost 6 years ago
There was also a follow up blog post again by Basri regarding how it&#x27;s tested using Jepsen for those interested: <a href="https:&#x2F;&#x2F;hazelcast.com&#x2F;blog&#x2F;testing-the-cp-subsystem-with-jepsen&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hazelcast.com&#x2F;blog&#x2F;testing-the-cp-subsystem-with-jep...</a>
heavenlybluealmost 6 years ago
What happens when some of the quorum members are not available?<p>The fact that split brain is not allowed implies that liveness is given up for it.<p>More importantly, what can I possibly do in the scenario where I would like to obtain several locks at the same time?<p>Distributed lock frameworks usually imply there’s some sort of transaction reversal mechanism implied by the architecture.
评论 #20107786 未加载
评论 #20106064 未加载
PaulHoulealmost 6 years ago
I love Hazelcast. It&#x27;s the best thing since the Coupling Facility on zSystem mainframes.
评论 #20109377 未加载