fix(task-board): 任务卡片假死自救——轮询失败退避重试+面板刷新按钮+补检轮进度文案
task 31769:外观专利任务后端 18:08 已 SUCCESS,但页面卡片冻在「正在组装 xlsx 92%」 一天多——Patent 轮询配的 propagate 让一次瞬时错误永久杀死轮询,且无自救出口。 - useLiveTaskBoard 摘除 pollErrorMode:失败一律吞掉重试,连续失败按倍数降频(封顶 5x) - TaskCenterPanel 头部新增「刷新」按钮,外观专利/货源查询两页接上(强拉 history+dashboard) - 补检轮触发时进度文案改「有 N 行未完成检测,补检中」,不再停在「正在组装 xlsx」假死 - 回归:AppearancePatentRecheckProgressMessageTest+task-board-poll-resilience.test.ts
This commit is contained in:
+6
-1
@@ -362,9 +362,14 @@ public class AppearancePatentResultJobSupport {
|
||||
progressSupport.saveFileBuildProgress(task, job, totalProgressUnits, assembleProgress, "正在组装 xlsx");
|
||||
// 补检决定必须做在出表之前:assembleResultWorkbook 一跑完就把 xlsx 传上 OSS 并挂好
|
||||
// resultFileUrl,那时才发现缺口,半张表已经在用户的下载列表里了。
|
||||
if (deliverySupport.requestRecheckForMissingRows(task, job, deliverySupport.measureDeliveryFacts(task, result))) {
|
||||
AppearancePatentRowOutcome.Facts gap = deliverySupport.measureDeliveryFacts(task, result);
|
||||
if (deliverySupport.requestRecheckForMissingRows(task, job, gap)) {
|
||||
// 半张表先不发出去:撤销未完成行的检测标记、把作业排回队列补检一轮,
|
||||
// 上限由行级轮次闸(llmRowMaxRounds)与补检轮次闸(recheckMaxRounds)共同兜住。
|
||||
// 进度消息同步换掉「正在组装 xlsx」:补检一轮常要几十分钟,卡片停在 92% 假死
|
||||
// (task 31769 实录),用户要看得见是在补检、不是卡死。百分比由快照棘轮保持不回退。
|
||||
progressSupport.saveFileBuildProgress(task, job, totalProgressUnits, assembleProgress,
|
||||
"有 " + gap.missingRows() + " 行未完成检测,补检中");
|
||||
return false;
|
||||
}
|
||||
AppearancePatentRowOutcome.Facts deliveryFacts = assembleResultWorkbook(task, result);
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.service.support;
|
||||
|
||||
import com.nanri.aiimage.modules.task.model.entity.FileResultEntity;
|
||||
import com.nanri.aiimage.modules.task.model.entity.FileTaskEntity;
|
||||
import com.nanri.aiimage.modules.task.model.entity.TaskFileJobEntity;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* 补检轮触发时进度文案必须换掉「正在组装 xlsx」(task 31769):
|
||||
* 补检一轮常要几十分钟,卡片一直停在 92%「正在组装 xlsx」,用户只能当成卡死;
|
||||
* 页面轮询恰好又被一次瞬时错误杀死后,这张假死卡挂了一天多(后端实际早已 SUCCESS)。
|
||||
* 这里钉住:recheck 分支要在返回 false 前把进度消息写成「有 N 行未完成检测,补检中」,
|
||||
* 首条「正在组装 xlsx」保持不变(组装阶段照旧)。
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AppearancePatentRecheckProgressMessageTest {
|
||||
|
||||
@Mock private AppearancePatentDeliverySupport deliverySupport;
|
||||
@Mock private AppearancePatentProgressSupport progressSupport;
|
||||
|
||||
@Test
|
||||
void recheckRoundWritesGapProgressInsteadOfFrozenAssembleMessage() {
|
||||
AppearancePatentRowOutcome.Facts gap =
|
||||
new AppearancePatentRowOutcome.Facts(5, 3, 0, List.of("B0AAAA", "B0BBBB"));
|
||||
when(deliverySupport.measureDeliveryFacts(task(), result())).thenReturn(gap);
|
||||
when(deliverySupport.requestRecheckForMissingRows(task(), job(), gap)).thenReturn(true);
|
||||
|
||||
Boolean proceeded = ReflectionTestUtils.invokeMethod(support(), "completeLlmFileJob",
|
||||
task(), result(), job(), 6);
|
||||
|
||||
assertFalse(proceeded, "补检轮触发时 completeLlmFileJob 必须返回 false(作业排回队列)");
|
||||
ArgumentCaptor<String> message = ArgumentCaptor.forClass(String.class);
|
||||
verify(progressSupport, times(2)).saveFileBuildProgress(eq(task()), eq(job()), eq(6), anyInt(), message.capture());
|
||||
assertEquals("正在组装 xlsx", message.getAllValues().get(0));
|
||||
assertEquals("有 2 行未完成检测,补检中", message.getAllValues().get(1));
|
||||
}
|
||||
|
||||
private AppearancePatentResultJobSupport support() {
|
||||
// 仅 deliverySupport / progressSupport 参与补检分支,其余协作者传 null(构造器只赋值)
|
||||
return new AppearancePatentResultJobSupport(
|
||||
"APPEARANCE_PATENT", 0L, null, null,
|
||||
null, null, null, null, null, null, null,
|
||||
null, null, null, deliverySupport, progressSupport, null,
|
||||
null, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
private FileTaskEntity task() {
|
||||
FileTaskEntity task = new FileTaskEntity();
|
||||
task.setId(31769L);
|
||||
task.setModuleType("APPEARANCE_PATENT");
|
||||
task.setStatus("RUNNING");
|
||||
return task;
|
||||
}
|
||||
|
||||
private TaskFileJobEntity job() {
|
||||
TaskFileJobEntity job = new TaskFileJobEntity();
|
||||
job.setId(22741L);
|
||||
job.setTaskId(31769L);
|
||||
job.setResultId(34819L);
|
||||
job.setStatus("RUNNING");
|
||||
return job;
|
||||
}
|
||||
|
||||
private FileResultEntity result() {
|
||||
FileResultEntity result = new FileResultEntity();
|
||||
result.setId(34819L);
|
||||
result.setTaskId(31769L);
|
||||
result.setModuleType("APPEARANCE_PATENT");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user