[Bug] Kyuubi Fails to Rearm the Engine Deregistration Watcher After ZooKeeper Reconnect
- Dominant language
- Scala
- Stars
- 2.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
### Search before asking
- [x] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues.
### Describe the bug
When a Kyuubi engine’s ZooKeeper session expires and reconnects, its deregistration watcher is not rearmed on the restored discovery node. As a result, deleting the node may fail to trigger graceful shutdown, allowing an unhealthy engine to remain discoverable and continue accepting new sessions.
### Affects Version(s)
master
### Kyuubi Server Log Output
```logtalk
```
### Kyuubi Engine Log Output
```logtalk
26/07/08 11:32:54 WARN ClientCnxn: Client session timed out ... sessionid 0x110dd5e23c59e86
26/07/08 11:33:52 WARN ClientCnxn: Client session timed out ... sessionid 0x309721e0b579613
26/07/08 11:33:52 INFO ClientCnxn: ... closing socket connection and attempting reconnect
26/07/08 11:33:52 INFO ZookeeperDiscoveryClient: Zookeeper client connection state changed to: SUSPENDED
26/07/08 11:33:53 WARN ClientCnxn: ... session 0x309721e0b579613 has expired
26/07/08 11:33:53 INFO ZookeeperDiscoveryClient: Zookeeper client connection state changed to: LOST
26/07/08 11:33:53 WARN ConnectionState: Session expired event received
26/07/08 11:33:53 INFO ZookeeperDiscoveryClient: Zookeeper client connection state changed to: RECONNECTED
26/07/08 11:33:53 WARN ClientCnxn: ... session 0x110dd5e23c59e86 has expired
26/07/08 11:33:53 INFO ZookeeperDiscoveryClient: Zookeeper client connection state changed to: LOST
26/07/08 11:33:53 WARN ConnectionState: Session expired event received
26/07/08 11:33:53 INFO ZookeeperDiscoveryClient: Zookeeper client connection state changed to: RECONNECTED
```
### Kyuubi Server Configurations
```yaml
```
### Kyuubi Engine Configurations
```yaml
```
### Additional context
_No response_
### Are you willing to submit PR?
- [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
- [ ] No. I cannot submit a PR at this time.
Contributor guide
Research direction
Start with the ZooKeeperDiscoveryClient connection-state handling shown in the engine logs, focusing on what happens after a session expires and the client reaches RECONNECTED. Verify that the deregistration watcher is restored on the discovery node, and confirm that deleting the node triggers graceful engine shutdown instead of leaving it discoverable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100