Repository navigation
fix(storage): 给 SQLite 启动初始化单独的写锁等待时间 - #538
Merged
qxcnm merged 2 commits intoNov 28, 2026
Merged
Conversation
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.
变更摘要
已完成迁移的 SQLite 数据库仍可能在 Web 启动检查时需要写锁。如果已有进程持有写事务超过常规请求的 3 秒等待时间,独立启动的
codexmanager-web会以状态码 1 退出,管理端口不会开始监听。API 服务此时可以继续正常运行。复现时使用全新的临时库和两个独立进程。先正常启动一次 Web 初始化数据库,退出 Web,在另一个 SQLite 连接执行
BEGIN IMMEDIATE并持锁 7 秒,再启动 Web。原版约在第 3.6 秒报storage init failed … (code: 5) database is locked。放锁后手动重启,同一数据库能正常提供管理页。改动范围
验证
cargo fmt --all -- --check、git diff --check通过。codexmanager-core全部 537 项、仓库内的rusqlite适配层全部 17 项、codexmanager-service的storage::helpers::tests11 项(默认并发及单线程分别运行),全部通过。cargo test --locked --offline -p codexmanager-web,默认特性的 Web 测试 48 项全部通过。本地共验证 613 个不同用例,未执行完整 workspace 测试。风险与影响面
持续占用数据库的写入者会增加 SQLite 启动等待时间。普通网关请求、数据库 schema、远程数据库后端和管理页鉴权沿用现有行为。