Skip to content

[bug] hub-server 泄漏 wget 僵尸进程,累计 150+ 不回收 #420

Description

@DeliciousBuding

现象

hk2 生产环境 td-agenthub 容器内 ./server-hub 进程(PID 5964)持续泄漏 wget 僵尸进程。

  • 发现时间:2026-07-12 23:44 HKT
  • 僵尸数量:148 → 150(持续增长)
  • 父进程./server-hub (PID 5964),AgentHub hub-server
  • 运行时长:自 2026-07-09 起约 3 天
  • 增长率:约 50/天

证据

# ps -eo pid,ppid,stat,comm | awk "\$3 ~ /Z/ {print}" | head -5
   1854    5964 Z    wget
  49875    5964 Z    wget
  64770    5964 Z    wget
  ...
# ps -eo stat | grep -c Z
150

# 所有僵尸的父进程
147  ppid=5964 (server-hub)
  1  ppid=1289582 (mihomo)

推测根因

Go 进程通过 os/execsyscall 调起 wget 子进程(可能是健康探活、外部资源拉取),但未调用 Wait() / Wait4() 回收子进程退出状态,导致僵尸累积。

影响

  • 每个僵尸占用一个 PID slot 和少量内核 task_struct 内存
  • 150 个尚不对系统产生实质压力,但单调增长最终会触达 pid_max
  • hk2 当前 steal 87-89% 已经是独立问题,与僵尸无关

临时处理

2026-07-13 已将生产 hk2 td-agenthub 容器停止,compose 中注释,nginx 中 agenthub config disabled。确认当前 AgentHub 无活跃用户流量(日志仅 health check)后执行。

期望修复

  1. 定位 server-hub 中调起 wget 的代码路径
  2. 确保子进程正确 Wait() 回收
  3. 如需外部健康探活,优先用 Go 内置 net/http 而非 shell out wget

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions