From af2702de8a75dc7366e7bec2c729939cdcdc197b Mon Sep 17 00:00:00 2001 From: weichen Date: Wed, 14 Oct 2026 04:15:17 +0000 Subject: [PATCH] Wait for recovery worker before releasing test fixtures (U5) Why: ResumeInterruptedChildren starts a background worker; the recovery-hold test returned while it could still write to a temporary workspace and SQLite store, causing cleanup races. Evidence: SELF Root e3a full combination exposed the TempDir/database-close race; the corrected target passed 100 repetitions and full Backend Go tests passed in /tmp/dependency-recovery-hold-wait-green-20261014-01a1345f.json and /tmp/dependency-backend-test-repair-all-go-green-20261014-01a1345f.json. Impact: Test teardown synchronization only; no production recovery behavior changes. Refs: Backend PR #196; Dev PR #537; R14/R15 --- internal/runmgr/recovery_hold_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/runmgr/recovery_hold_test.go b/internal/runmgr/recovery_hold_test.go index ed3e3c6..20e1c1b 100644 --- a/internal/runmgr/recovery_hold_test.go +++ b/internal/runmgr/recovery_hold_test.go @@ -80,6 +80,13 @@ func TestRecoveryHoldBlocksResumeUntilReleased(t *testing.T) { if held, herr := st.HasOpenRecoveryHold(child.ID, string(child.ConversationID)); held || herr != nil { t.Fatalf("解除后不应再有 hold:held=%v err=%v", held, herr) } + // ResumeInterruptedChildren 启动后台续跑。等它完成后再让测试关闭数据库 + // 和删除临时工作区,避免续跑与 t.Cleanup 并发写同一现场。 + waitUntil(t, func() bool { + c.mgr.noticeMu.Lock() + defer c.mgr.noticeMu.Unlock() + return c.mgr.bgInFlight[c.run.ConversationID] == 0 + }) } // 会话级 hold:同会话的其他中断子 run 一并跳过(副作用疑点未核对前,