ManguoLabsTech commented on issue #39690:
URL: 
https://github.com/apache/shardingsphere/issues/39690#issuecomment-5506478954

   这是跨区域网络分区后 ZooKeeper 连接池未完全恢复的典型问题。Curator 后台重试失败说明连接状态管理出现异常。
   
   ## 问题定位
   
   `CuratorConnectionLossException` 持续出现表明:
   
   - 注册中心元数据缓存损坏
   
   - Curator TreeCache 连接句柄未正确重建
   
   - 部分 Proxy 节点与 ZooKeeper 集群的网络路径仍然存在问题
   
   重启所有节点后仍有错误,说明不是简单的连接超时,而是元数据层或 ZooKeeper 集群本身的问题。
   
   ## 排查步骤
   
   检查 ZooKeeper 集群健康状态:
   
   ```bash
   echo stat | nc <zk-host> 2181
   echo mntr | nc <zk-host> 2181 | grep outstanding
   ```
   
   确认所有 ZooKeeper 节点的会话连接数和网络延迟。
   
   检查 Proxy 到 ZooKeeper 的实际连接:
   
   ```bash
   netstat -an | grep 2181
   ```
   
   查看 ShardingSphere 注册中心配置的超时参数:
   
   ```yaml
   mode:
     type: Cluster
     repository:
       type: ZooKeeper
       props:
         timeToLiveSeconds: 60
         retryIntervalMilliseconds: 500
         maxRetries: 3
   ```
   
   ## 解决方案
   
   清理 ZooKeeper 上的陈旧元数据:
   
   ```bash
   zkCli.sh -server <zk-host>:2181
   ls /shardingsphere
   deleteall /shardingsphere/metadata
   ```
   
   注意备份现有配置后再删除。
   
   调整 Curator 重试策略,在 Proxy 启动参数中增加:
   
   ```bash
   -Dcurator-default-connection-timeout=10000
   -Dcurator-default-session-timeout=60000
   ```
   
   如果跨区域延迟较高,建议:
   
   - 每个区域部署独立 ZooKeeper 集群
   
   - 使用 Proxy 联邦模式而非单一注册中心
   
   - 增大 `timeToLiveSeconds` 和会话超时参数
   
   ## 验证
   
   重启后执行:
   
   ```bash
   show processlist;
   ```
   
   观察 Proxy 日志中是否还有 `Background retry gave up`,同时检查返回的数据库连接数是否完整。
   
   如果问题依然存在,需要提供完整的 ZooKeeper 版本、网络拓扑(跨区域延迟数据)以及 Proxy 集群规模信息进行深入分析。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to