Skip to content

[Bug]启动后过一段时间,CPU占用极高,epoll_wait非阻塞忙等 #8056

@mnigc

Description

@mnigc

What happened / 发生了什么

问题描述

AstrBot 运行一段时间后,服务器单核CPU被占满(100%),监控显示用户态占用97%+。

关键诊断信息

  1. top 命令显示:python 进程 CPU 占用 99%,PID=265298
  2. strace 诊断:主线程无限循环执行 epoll_wait(6, [], 3, 0) = 0,非阻塞忙等
  3. ps -T 显示:仅主线程占用CPU,子线程空闲
  4. 应该异步事件循环死循环 bug

Reproduce / 如何复现?

  1. 正常启动 AstrBot
  2. 经过内置chat、飞书聊天等几轮对话,CPU可能会随时跑满
  3. 可能原因:WAL数据库超过主数据库占用,系统频繁读写

如果 WAL 很大(如 6MB):

  • 先读主库 3.8MB
  • 再读 WAL 6MB 中的相关变更
  • 合并结果返回
  • 每次查询都要扫描大量 WAL → CPU 飙高

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

1panel docker部署

  • 系统:Linux(ubuntu24、debian12)
  • AstrBot 版本:4.24.2
  • Python 版本:3

OS

Linux

Logs / 报错日志

Image Image Image Image

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreThe bug / feature is about astrbot's core, backendbugSomething isn't workingpriority: p0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions