Repository navigation
fix(delete): 统一「D1 删成功 = 业务成功」,R2 清理失败留孤儿 - #13
Merged
Merged
Conversation
删除顺序仍是先 D1 后 R2(反转一旦失败就是整库悬空),改的是后半段的错误处理: 此前 R2 清理抛错会让已经删掉行的请求变成 500 —— 用户看到失败、数据其实没了, 重试也删不掉(行已不在),只会误导。 - src/historyOps.ts:deleteRecordsWorkingDirs 改 best-effort,内部 catch 后 打 '[cleanup] deferred R2 cleanup' 日志;clearAllHistory/purgeTrash 照常返回条数。 - src/ui/routes.ts:batch-purge 单条 R2 删失败不再把整批变 500(D1 删成功计入 purged, 目录失败只留日志,由孤儿阶段兜底)。 - test/fixes.test.ts:注入 Bucket.delete 抛错,验证 purgeTrash/clearAllHistory 仍返回 删除条数且行确实已删;阳性对照证明无故障时字节确实被清。 - docs/design.md §6:登记删除的成功语义。
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
leeefun
added a commit
that referenced
this pull request
Oct 6, 2026
评审指出:#16 基于旧 master,其 historyOps.ts / routes(移动后) 仍是裸的 deleteHistoryWorkingDir,没有 #13 的 best-effort 语义 ⇒ 若 #16 先合会退掉 #13。 本提交把 #13 的改动原样前向移植(使 #16 rebase 时无实质冲突): - src/historyOps.ts:deleteRecordsWorkingDirs 改 best-effort(catch + '[cleanup] deferred R2 cleanup')。 - src/ui/routes/history-mutations.ts:batch-purge 单条 R2 删失败不再把整批变 500。 - test/fixes.test.ts:FakeBucket.failDelete 注入 + 三条用例(purgeTrash/clearAllHistory/阳性对照)。 - docs/design.md §6:登记删除成功语义。
leeefun
added a commit
that referenced
this pull request
Oct 7, 2026
评审指出:#16 基于旧 master,其 historyOps.ts / routes(移动后) 仍是裸的 deleteHistoryWorkingDir,没有 #13 的 best-effort 语义 ⇒ 若 #16 先合会退掉 #13。 本提交把 #13 的改动原样前向移植(使 #16 rebase 时无实质冲突): - src/historyOps.ts:deleteRecordsWorkingDirs 改 best-effort(catch + '[cleanup] deferred R2 cleanup')。 - src/ui/routes/history-mutations.ts:batch-purge 单条 R2 删失败不再把整批变 500。 - test/fixes.test.ts:FakeBucket.failDelete 注入 + 三条用例(purgeTrash/clearAllHistory/阳性对照)。 - docs/design.md §6:登记删除成功语义。
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.
问题
删除的顺序是"先 D1 删行、后 R2 清数据目录"(这个顺序必须保留——反过来一旦 DELETE 失败就是整库悬空)。但后半段的 R2 清理失败会把一次已经生效的删除变成 500:用户看到失败、数据其实没了、重试也删不掉(行已不在),只会误导。
改动
统一语义:D1 完成永久删除 = 业务删除成功;随后 R2 清理失败 = 留下 orphan,由 Cron 的孤儿阶段回收,同时打可观测日志。
src/historyOps.ts:deleteRecordsWorkingDirs改 best-effort,内部 catch 后console.warn('[cleanup] deferred R2 cleanup', …);clearAllHistory/purgeTrash照常返回删除条数。src/ui/routes.ts:batch-purge单条 R2 删失败不再把整批变 500(D1 删成功计入purged)。docs/design.md§6 登记该成功语义。未引入 D1/R2 两阶段提交或事务模拟。
验证
test/fixes.test.ts注入Bucket.delete抛错:purgeTrash/clearAllHistory仍返回删除条数,且行确实已删;tsc/eslint干净;全量套件 22/22 通过。