Apache Zookeeper/Curator 在锁上的生存时间 [英] Apache Zookeeper / Curator time-to-live on locks

查看:39
本文介绍了Apache Zookeeper/Curator 在锁上的生存时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Curator 锁配方(或较低级别的 ZooKeeper)中是否有任何工具可用于自动释放超过某个 TTL 的锁?如果没有,是否有处理该问题的最佳做法?我看到 Curator 会在客户端连接丢失的情况下自动释放锁,这很好……而且锁获取超时也很有帮助.

Is there any facility in the Apache Curator lock recipes (or lower-level ZooKeeper) for auto-releasing locks that have exceeded some TTL? If not, is there a best practice for dealing with that? I see that Curator automatically releases locks in the case of the client connection being lost, which is nice...and the timeout on lock acquisition is also helpful.

我想知道我需要在多大程度上保护我的系统,通过重复性的工作来寻找已经存在很长时间的锁并手动释放它们.我可以通过让我的单独进程直接删除相关的 ZNode 来做到这一点吗?

I'm wondering to what degree I need to protect my system by making a recurring job that looks for locks that have been around to long and manually releasing them. Would I do that by having my separate process directly delete the relevant ZNode?

推荐答案

Curator 的锁是使用 EPHEMERAL znodes 实现的.所以,如果锁持有者以某种方式变得不稳定,ZooKeeper 应该自动释放锁.如果您正在寻找一种方法来撤销其他进程持有的锁,那么 Curator 的一些锁配方具有协作撤销功能.除此之外,从进程下面删除锁似乎会导致极大的不稳定性.我想不出这样做的充分理由.

Curator's locks are implemented using EPHEMERAL znodes. So, if the lock holder becomes unstable in some way, ZooKeeper should automatically release the lock. If you're looking for a way to revoke locks held by other processes, some of Curator's lock recipes have a cooperative revoking facility. Other than that, deleting a lock from underneath a process seems like it would cause tremendous instability. I can't think of a good reason to do it.

(注:我是策展人的主要作者)

(note: I'm the main author of Curator)

这篇关于Apache Zookeeper/Curator 在锁上的生存时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆