From fa4588a1198161d41a194a862c3927c895890bd9 Mon Sep 17 00:00:00 2001 From: host Date: Thu, 5 Nov 2026 02:54:22 +0800 Subject: [PATCH] CI: guard coordinator pushback test flips on parent still running (run #20 flake: post-commit flip re-failed requeued child on slow runner; test-only, no production change) --- cloud/tests/test_audit_loop_coord.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cloud/tests/test_audit_loop_coord.py b/cloud/tests/test_audit_loop_coord.py index 94e2544..1020c42 100644 --- a/cloud/tests/test_audit_loop_coord.py +++ b/cloud/tests/test_audit_loop_coord.py @@ -373,12 +373,25 @@ class CoordAuditTestCase(unittest.TestCase): while time.time() < deadline: conn = sqlite3.connect(self.db_path) try: + # 翻状态与父任务终态判定必须在同一条语句里原子 + # 完成:只在父任务仍 running 时翻子任务。旧写法 + # 是无条件翻状态,合流提交推回(父回 queued、子 + # 回 queued)之后、协调员线程退出之前,翻状态线 + # 程的下一拍会把已重排的 C1 重新翻回 failed,慢 + # 机器上即表现为“父 queued、子 failed”的假失败 + # (Gitea run #20 唯一失败项正是此断言;产品侧 + # 合流本身无问题,直接调合流的 test_merge_pushback + # 在同一轮 CI 里通过)。 conn.execute( "UPDATE tasks SET status = 'failed'," - " error_text = 'boom' WHERE id = 'C1'") + " error_text = 'boom' WHERE id = 'C1' AND" + " (SELECT status FROM tasks WHERE id = 'P1')" + " = 'running'") conn.execute( "UPDATE tasks SET status = 'completed'," - " result_text = 'done' WHERE id = 'C2'") + " result_text = 'done' WHERE id = 'C2' AND" + " (SELECT status FROM tasks WHERE id = 'P1')" + " = 'running'") conn.commit() finally: conn.close()