fix: 保留系统包管理器锁状态 - #5217
Closed
eyaeya wants to merge 1 commit into
Closed
fix: 保留系统包管理器锁状态#5217eyaeya wants to merge 1 commit into
eyaeya wants to merge 1 commit into
Conversation
Closed
eyaeya
force-pushed
the
net/package-manager-lock-state
branch
from
July 8, 2026 11:20
d517389 to
53bd14f
Compare
This was referenced Jul 8, 2026
Closed
Closed
Closed
Contributor
Author
|
这个拆分 PR 已被新的合并版 PR 取代:#5231 原因:#5217、#5218、#5222 都属于更新/版本状态健壮性修复,并且按任意顺序合并时会在 已在合并版 PR 中验证:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dependency chain
无依赖,可独立合并。建议先于自动更新类改动合并,避免后续更新路径继续继承系统锁误删行为。
问题现象
OpenClash 在版本显示、调试信息、历史缓存判断和版本更新预检查中,会直接删除
/var/lock/opkg.lock或/lib/apk/db/lock。如果系统里同时有 LuCI、用户 shell 或系统 feed 操作在运行,这会绕过包管理器自身互斥,让两个包管理流程并发访问同一数据库。根因
这些路径只是读取包版本、CPU 架构或执行
opkg update/apk update,但代码在读取前后无条件rm -f系统包管理器锁文件。锁文件属于 opkg/apk 的互斥状态,不应由 OpenClash 的查询脚本清理。证据
openclash_update.sh原先在读取当前版本、opkg update/apk update后、安装脚本校验版本时删除系统锁。openclash_version.sh、openclash_debug.sh、openclash_history_get.sh原先在只读查询前删除系统锁。luasrc/openclash.lua和 controller 中也存在同类只读查询前删锁。tests/openclash_package_lock_test.sh对整个luci-app-openclash做回归扫描,防止这些路径重新引入系统锁删除。修复方案
opkg status、apk list/info、opkg update、apk update调用和错误处理,不改变下载代理、重试次数或安装流程。为什么没有扩大范围
本 PR 只处理“OpenClash 不应删除系统包管理器锁”这一项。后台安装期间固定包路径、OpenClash 自有
flock锁文件删除、启动状态判断等是独立竞态问题,应单独审查和提交,避免把不同风险混成一个大改动。与已有开启态 PR 的关系
验证
bash -n luci-app-openclash/root/usr/share/openclash/*.sh:通过bash -n luci-app-openclash/root/etc/init.d/openclash:通过bash -n tests/*.sh:通过for t in tests/*.sh; do bash "$t"; done:全部通过git diff --check:通过rg -n '^(<<<<<<<|=======|>>>>>>>)':无匹配未做 live router 写入验证;本次不触碰真实路由器配置和包数据库。
剩余风险
如果
opkg update或apk update被超时强杀后包管理器自身留下不可恢复的 stale lock,需要另行做 owner-aware 的超时恢复策略;本 PR 不恢复无条件删锁行为。