Zookeeper 临时节点是否写入磁盘?

Are Zookeeper ephemeral nodes written to disk?

Zookeeper 临时节点是否写入磁盘?

我知道正常的 Zookeeper 节点会在 Zookeeper 确认写入客户端之前写入磁盘。

但是,临时节点仅在客户端会话期间存在,因此如果 zookeeper 节点全部崩溃,则根据定义客户端会话已中断。因此不需要写入磁盘,因为当整体重新启动时不会重新创建临时节点。所以理论上似乎临时节点只需要存储在内存中。

是这样实现的吗?

我自己 运行 进入这个问题,并注意到它已经在 Zookeeper mailing list 上得到了回答,我将它张贴在这里以供发现此问题的任何人使用。

简而言之,是的,临时节点确实写入了磁盘。因此,即使整个 Zookeeper 整体关闭,客户端会话也可以持续存在。引用 Patrick Hunt's answer from the mailing list(强调我的):

Ephemeral znodes are treated just like persistent znodes in the sense that a quorum of nodes need to agree to any change. As such the znode is written to the transaction log.

A client session ends either when a client closes it's session explicitly or the ZK quorum leader decides that the session has expired (which is based on the negotiated session timeout). Only while a leader is active can a session be expired (or closed for that matter). When you shutdown an ensemble the sessions are maintained. If you were to, for example, shut down an ensemble for an hour and then restart it the sessions would still be active. The clock would "reset" when the new leader was elected. If the client session is still active the session would continue, any ephemeral znodes would still exist.