From 9cd0cec8c63f186b40174f8b198606b5714f1731 Mon Sep 17 00:00:00 2001 From: zhang-arvin Date: Mon, 31 Aug 2026 16:01:49 +0800 Subject: [PATCH] [KYUUBI-7556] Fix engine deregistration watcher not rearmed after ZK reconnect --- .../ha/client/zookeeper/ZookeeperDiscoveryClient.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/zookeeper/ZookeeperDiscoveryClient.scala b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/zookeeper/ZookeeperDiscoveryClient.scala index bead620536a..7b16332ac4b 100644 --- a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/zookeeper/ZookeeperDiscoveryClient.scala +++ b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/zookeeper/ZookeeperDiscoveryClient.scala @@ -106,7 +106,14 @@ class ZookeeperDiscoveryClient(conf: KyuubiConf) extends DiscoveryClient { override def stateChanged(client: CuratorFramework, newState: ConnectionState): Unit = { info(s"Zookeeper client connection state changed to: $newState") newState match { - case CONNECTED | RECONNECTED => isConnected.set(true) + case CONNECTED => isConnected.set(true) + case RECONNECTED => + isConnected.set(true) + // Re-arm the de-registration watcher after ZK session reconnects, + // as watches are cleared when the session expires. + if (serviceNode != null && watcher != null) { + watchNode() + } case LOST => isConnected.set(false) val delay = getGracefulStopThreadDelay(conf)