A second failed update rollback restores a stale -wal from an earlier failed rollback

未关闭 适合新手
#1,234 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
sqlite, typescript
领域
backend, databases

调研方向

从src/updater/index.ts中的backupDatabases和restoreDatabases开始,然后阅读src/updater/AGENTS.md中的第 5 步,了解备份文件夹的生命周期。检查 updater 测试是否覆盖备份和回滚,并运行相关测试。完成标准是:回滚只恢复该次更新创建备份时已存在的 sidecar 文件,即使之前的回滚失败过也是如此。

由索引模型根据 Issue 内容生成。

描述

bug:new

An update whose new daemon fails to start can restore a stale SQLite -wal file next to a newer database, when an earlier update's rollback had also failed.

backupDatabases (src/updater/index.ts:159) creates update-backup with mkdirp and copies only the sidecar files that exist now; it never removes ones already in the folder. restoreDatabases (:172) copies back every sidecar it finds there. The folder is deleted after a good start or a good rollback, so it survives only after a rollback that failed (src/updater/AGENTS.md, step 5). A clean daemon stop leaves no -wal, so the old -wal from that earlier attempt stays in the backup, and the second rollback puts it beside the current state.db. SQLite may then replay or reject a WAL that does not belong to that database, so the restored state can be wrong or the database unreadable.

Steps. (1) An update whose start fails and whose rollback also fails, leaving update-backup with a -wal. (2) A clean stop. (3) A second update whose new daemon fails to start, so it rolls back. The live state.db-wal is now the one from step 1.

Expected. A rollback restores exactly the files that existed when that update's backup was taken.

Possible fix. Empty (or remove) update-backup at the start of backupDatabases.

Found in a code review, checked by hand.

Written by an agent.

主要语言
TypeScript
星标
535
派生
21
平均合并
9 小时 26 分钟
30 天内合并 PR
437

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/simlock 的其他 Issue

查看 callstackincubator/simlock 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。