Zookeeper locks use ephemeral nodes. An ephemeral node is a node that lives as long as the session that created it is alive. Sessions are kept alive by the process creating the session periodically sending a heartbeat message to zookeeper.
So if you kill the process that created the lock, the lock will eventually be released, as the session will die as zookeeper no longer receives heartbeats.
So killing a worker before the lock is released should eventually release the lock.
If the lock is never released, a couple things could be happening,
- Someone else noticed the lock was released and obtained it. Presumably you are locking because there is contention, and some other process will try and acquire the lock when it is released.
- You aren't waiting long enough. When you connect to zookeeper there should be a session timeout parameter you set, that is how long the server will keep the session alive without hearing any heartbeats, you have to wait this long to see the locks released
- There is a bug in kazoo. This is possible, but it looks like the kazoo lock recipe uses ephemeral nodes, and the use case you describe is a very basic one.
It is very unlikely this is a zookeeper bug.
How do you know the lock is not being released?