Skip to content

执行 xray api rmrules 时 CPU 和内存开销均飙升至 100% #5717

@asbai

Description

@asbai

完整性要求

  • 我读完了 issue 模板中的所有注释,确保填写符合要求。
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
  • 我搜索了 issues, 没有发现已提出的类似问题。
  • 问题在 Release 最新的版本上可以成功复现

描述

调用 api adrules 后,再调用 rmrules 或 lsrules 均会引发 CPU 和内存 100%。

重现方式

  1. systemctl restart xray

  2. xray api adrules << EOF
    {
    "routing": {
    "rules": [
    {
    "tag": "rule-2222",
    "type": "field",
    "inboundTag": ["in-2222"],
    "outboundTag": "out-2222"
    }
    ]
    }
    }
    EOF

  3. xray api rmrules 'rule-2222'

执行第 3 步后 CPU 和内存均 100%

xray version
Xray 26.2.6 (Xray, Penetrates Everything.) 12ee51e (go1.25.7 linux/amd64)
A unified platform for anti-censorship.

客户端配置

服务端配置

{
"log": {
"loglevel": "warning"
},
"api": {
"tag": "api",
"services": [
"HandlerService",
"RoutingService"
]
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 8080,
"protocol": "dokodemo-door",
"settings": { "address": "127.0.0.1" },
"tag": "api-in"
}
],
"outbounds": [
{
"tag": "out-direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "block-out",
"protocol": "blackhole",
"settings": {}
}
],
"routing": {
"rules": [
{ "inboundTag": ["api-in"], "outboundTag": "api", "type": "field" }
]
}
}

客户端日志

服务端日志

Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.995664 from 127.0.0.1:15758 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.996028 from 127.0.0.1:15770 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.996312 from 127.0.0.1:15776 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.996609 from 127.0.0.1:15782 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.996891 from 127.0.0.1:15802 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.997349 from 127.0.0.1:15804 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.997632 from 127.0.0.1:15818 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.997949 from 127.0.0.1:15832 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.998239 from 127.0.0.1:15834 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.998533 from 127.0.0.1:15836 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.998801 from 127.0.0.1:15852 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.999215 from 127.0.0.1:15858 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.999626 from 127.0.0.1:15860 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:03 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:03.999914 from 127.0.0.1:15876 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.000220 from 127.0.0.1:15878 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.000507 from 127.0.0.1:15894 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.000820 from 127.0.0.1:15908 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.001130 from 127.0.0.1:15922 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.001429 from 127.0.0.1:15944 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.001704 from 127.0.0.1:15946 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.001976 from 127.0.0.1:15954 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.002284 from 127.0.0.1:15966 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.002599 from 127.0.0.1:15978 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.002878 from 127.0.0.1:15992 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.003151 from 127.0.0.1:16000 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.003464 from 127.0.0.1:16020 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.003805 from 127.0.0.1:16022 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.004082 from 127.0.0.1:16044 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.004368 from 127.0.0.1:16046 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.004653 from 127.0.0.1:16058 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.004916 from 127.0.0.1:16064 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.005195 from 127.0.0.1:16072 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.005476 from 127.0.0.1:16086 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.005771 from 127.0.0.1:16092 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.006050 from 127.0.0.1:16098 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]
Feb 22 06:25:04 AZ-ZY-G0-SGr2 xray[150297]: 2026/02/22 06:25:04.006333 from 127.0.0.1:16112 accepted tcp:127.0.0.1:8080 [api-in >> out-direct]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions