fix(b82-01): 任务行部分字段落库改 update(null, wrapper),13 处部分实体 updateById 不再抹 failure_category
B82-01:failureCategory 标 FieldStrategy.ALWAYS(V186 让清错误分支的 null 真落库)的代价是任何 new 出来的部分实体走 updateById 都把该列无条件抹回 NULL。现网只读探针(2026-11-05,SSH 主机B)实证列全表零非空:近 7 天 194 条 FAILED 全空,9 条文案命中 CREDENTIAL/DELIVERY markers 的行列也是空。本笔只动调用点一边;注解半边由 TaskFailureCategoryMigrationV186Test 的 ALWAYS 钉守住。 写点转换(13 处 updateById,12 个条目,DedupeRunService 收尾一处两调用):convert/split/productrisk/queryasin/withdraw/similarasin/appearance-patent/pricetrack 显式两到四列;shopdatacrawl 快照+归属三列;deletebrand 终态分支 error_message 与分类同笔配对 TaskFailureLedger.categoryOf(护栏格1连线语义);dedupe FAILED 收尾同笔配对;similarasin 归属绑定(rustfs 回退)。Explore 初判 12 处漏了 withdraw/pricetrack 族——逐支验明全是 loadTaskForExecution 全实体(selectById/缓存血统),非抹列点,留痕不扩 scope;DELIVERY/CREDENTIAL 两族终态写点接 ledger 属后续批,不在本笔。 护栏 TaskFailureCategoryGuardrailTest 5→7:① ledger 对六组 markers 各出一条值非空断言(配对写恒 NULL 也绿那半堵上);② .updateById( 总量棘轮 173→160(本仓 ALWAYS 字段还有 PriceTrackLoopRun/ShopKey/SkipPriceAsin 四实体,棘轮按全量钉,新增写法必须登记复审)。测试适配:共享探针 UpdateWrapperProbe(getSqlSet 列序+MPGENVAL 精确取值+列名 snake 归一——单测 JVM 的 Lambda 列缓存可能被自动初始化成驼峰,不归一则快照取决于测试类执行顺序);4 份 golden 重钉 11 行(窄写面 status 不在写面渲染成 -);ShopDataCrawlOwnerColumnTest 假 DB 从只会 CAS 升级为按 SQL 语义应用 SET 段(whereEq 校验 id/status eq);SimilarAsinTaskServiceSubmitTest 归属断言改为录 SET 段断言零 owner_instance_id(touchJavaSideTaskActivity 本就合法走 update(null,wrapper),verify(never) 会误杀)。 门禁:受影响七支定向 50/0 失败/0 错误/3 skipped(既有 skip,零新增);mvn -o test 整量 5321/0 失败/0 错误/19 skipped BUILD SUCCESS(5:01,skip 数与在册基线逐字相同);后端无 lint/格式器如实跳过;未动 application.yml/路由/Flyway/env,门禁5不适用。
This commit is contained in:
+6
-1
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.service.support;
|
||||
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.task.FailedStatusRowFilter;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
@@ -212,7 +213,11 @@ public final class AppearancePatentParsePipeline {
|
||||
long payloadStoredAt = System.nanoTime();
|
||||
task.setResultJson(payloadSupport.get().buildTaskResultJson(request.getAiPrompt(), request.getApiKey(), sourceFiles, parsedPayloadPointer));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写载荷与心跳两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()));
|
||||
|
||||
String sourceFilename = buildAggregateSourceFilenameLabel(sourceFiles);
|
||||
// rowCount 记接受行数、success 留 NULL(本支建单不写占位值),这两列底座刻意不替它定
|
||||
|
||||
+9
-1
@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
@@ -191,7 +192,14 @@ public class ConvertRunService {
|
||||
task.setFailedFileCount(failedCount);
|
||||
task.setResultJson(JSONUtil.toJsonStr(items));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写计数/载荷/心跳四列——部分实体 updateById 会把 ALWAYS 的
|
||||
// failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount())
|
||||
.set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()));
|
||||
|
||||
ConvertRunVo vo = new ConvertRunVo();
|
||||
vo.setTotal(request.getFiles().size());
|
||||
|
||||
+19
-2
@@ -404,7 +404,16 @@ public class DedupeRunService {
|
||||
task.setErrorMessage(progress.getError());
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
task.setFinishedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:收尾用的还是建单那枚内存实体,updateById 会把 ALWAYS 的 failure_category
|
||||
// 抹回 NULL(陈旧修复面刚写进的分类一并被抹)。显式 wrapper 只写本方法的四列,
|
||||
// error_message 与分类同笔落库(护栏格 1 的连线语义)
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getStatus, task.getStatus())
|
||||
.set(FileTaskEntity::getErrorMessage, task.getErrorMessage())
|
||||
.set(FileTaskEntity::getFailureCategory, TaskFailureLedger.categoryOf(task.getErrorMessage()))
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())
|
||||
.set(FileTaskEntity::getFinishedAt, task.getFinishedAt()));
|
||||
} finally {
|
||||
// 终态必须绕过节流立刻共享:客户端下一次轮询可能落到另一节点
|
||||
runProgressMap.putNow(runId, snapshot(progress));
|
||||
@@ -496,7 +505,15 @@ public class DedupeRunService {
|
||||
task.setResultJson(JSONUtil.toJsonStr(result.getItems()));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
task.setFinishedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:同收尾分支——显式 wrapper 只写本方法的六列,不带抹 failure_category
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getStatus, task.getStatus())
|
||||
.set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount())
|
||||
.set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())
|
||||
.set(FileTaskEntity::getFinishedAt, task.getFinishedAt()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+16
-1
@@ -4,6 +4,7 @@ import com.nanri.aiimage.common.text.UserMessages;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
@@ -41,6 +42,7 @@ import com.nanri.aiimage.modules.task.service.TaskDistributedLockService;
|
||||
import com.nanri.aiimage.modules.task.service.TaskFileJobService;
|
||||
import com.nanri.aiimage.modules.task.service.TaskFinalizeSupport;
|
||||
import com.nanri.aiimage.modules.task.service.pipeline.AbstractFileTaskPipeline;
|
||||
import com.nanri.aiimage.modules.task.service.support.TaskFailureLedger;
|
||||
import com.nanri.aiimage.modules.ziniao.model.vo.ZiniaoShopMatchResultVo;
|
||||
import com.nanri.aiimage.modules.ziniao.service.ZiniaoShopIndexService;
|
||||
import com.nanri.aiimage.modules.ziniao.service.ZiniaoShopSwitchService;
|
||||
@@ -282,12 +284,25 @@ public class DeleteBrandRunService extends AbstractFileTaskPipeline<DeleteBrandP
|
||||
task.setResultJson(toCompactTaskResultJsonForDb(items));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
task.setSourceFileCount(processableFileCount);
|
||||
// B82-01:task 是建单内存实体,updateById 会把 ALWAYS 的 failure_category 抹回 NULL——
|
||||
// 显式 wrapper 只写本方法要改的列;终态分支的 error_message 与分类同笔落库(护栏格 1 的连线语义)
|
||||
LambdaUpdateWrapper<FileTaskEntity> persist = new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getSuccessFileCount, parsedSuccessCount)
|
||||
.set(FileTaskEntity::getFailedFileCount, parsedFailedCount)
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, LocalDateTime.now())
|
||||
.set(FileTaskEntity::getSourceFileCount, processableFileCount);
|
||||
if (processableFileCount <= 0) {
|
||||
task.setStatus("FAILED");
|
||||
task.setErrorMessage(parsedFailedCount > 0 ? "全部文件解析或匹配失败" : null);
|
||||
task.setFinishedAt(LocalDateTime.now());
|
||||
persist.set(FileTaskEntity::getStatus, task.getStatus())
|
||||
.set(FileTaskEntity::getErrorMessage, task.getErrorMessage())
|
||||
.set(FileTaskEntity::getFailureCategory, TaskFailureLedger.categoryOf(task.getErrorMessage()))
|
||||
.set(FileTaskEntity::getFinishedAt, task.getFinishedAt());
|
||||
}
|
||||
fileTaskMapper.updateById(task);
|
||||
fileTaskMapper.update(null, persist);
|
||||
if ("RUNNING".equals(task.getStatus())) {
|
||||
deleteBrandTaskCacheService.saveTaskCache(task);
|
||||
}
|
||||
|
||||
+7
-1
@@ -3,6 +3,7 @@ package com.nanri.aiimage.modules.pricetrack.service;
|
||||
import com.nanri.aiimage.common.task.TaskStatuses;
|
||||
import com.nanri.aiimage.common.text.UserMessages;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
@@ -660,7 +661,12 @@ public class PriceTrackTaskService extends AbstractShopPayloadTaskPipeline<Price
|
||||
} catch (Exception ex) {
|
||||
throw new BusinessException("序列化任务数据失败");
|
||||
}
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写快照两列——task 是建单内存实体,updateById 会把 ALWAYS 的
|
||||
// failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getRequestJson, task.getRequestJson())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson()));
|
||||
priceTrackTaskCacheService.saveTaskCache(task);
|
||||
|
||||
// TODO: Python 侧轮询 RUNNING 任务,pickup 后开始处理
|
||||
|
||||
+7
-1
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.productrisk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
@@ -560,7 +561,12 @@ public class ProductRiskTaskService {
|
||||
} catch (Exception ex) {
|
||||
throw new BusinessException("序列化任务数据失败");
|
||||
}
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写快照两列——task 是建单内存实体,updateById 会把 ALWAYS 的
|
||||
// failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getRequestJson, task.getRequestJson())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson()));
|
||||
|
||||
ProductRiskCreateTaskVo vo = new ProductRiskCreateTaskVo();
|
||||
vo.setTaskId(task.getId());
|
||||
|
||||
+5
-1
@@ -706,7 +706,11 @@ public class QueryAsinTaskService {
|
||||
task.setRequestJson(objectMapper.writeValueAsString(requestItems));
|
||||
task.setResultJson(objectMapper.writeValueAsString(snapshots));
|
||||
syncSnapshotTables(task, snapshots);
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写快照两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getRequestJson, task.getRequestJson())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson()));
|
||||
} catch (Exception ex) {
|
||||
throw new BusinessException("查询ASIN任务快照保存失败");
|
||||
}
|
||||
|
||||
+6
-1
@@ -1361,7 +1361,12 @@ public class ShopDataCrawlTaskService extends AbstractFileTaskPipeline<ShopDataC
|
||||
task.setRequestJson(objectMapper.writeValueAsString(requestSnapshot));
|
||||
task.setOwnerInstanceId(currentInstanceId());
|
||||
persistSnapshotJson(task, snapshots);
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写快照与归属三列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getRequestJson, task.getRequestJson())
|
||||
.set(FileTaskEntity::getOwnerInstanceId, task.getOwnerInstanceId())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson()));
|
||||
} catch (Exception ex) {
|
||||
throw new BusinessException("店铺数据抓取任务快照保存失败");
|
||||
}
|
||||
|
||||
+5
-1
@@ -482,7 +482,11 @@ public class SimilarAsinTaskService implements SimilarAsinPipelineHost {
|
||||
long payloadStoredAt = System.nanoTime();
|
||||
task.setResultJson(payloadSupport().buildTaskResultJson(request.getAiPrompt(), request.getApiKey(), request.getImgSwitch(), request.getCategorySwitch(), sourceFiles, parsedPayloadPointer));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写载荷与心跳两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()));
|
||||
|
||||
String sourceFilename = buildAggregateSourceFilenameLabel(sourceFiles);
|
||||
FileResultEntity result = new FileResultEntity();
|
||||
|
||||
+7
-5
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.similarasin.service.support;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
@@ -164,11 +165,12 @@ public class SimilarAsinTaskOwnershipSupport {
|
||||
payload.put("ownerInstanceReason", "rustfs-fallback-local");
|
||||
String updatedJson = objectMapper.writeValueAsString(payload);
|
||||
task.setResultJson(updatedJson);
|
||||
FileTaskEntity update = new FileTaskEntity();
|
||||
update.setId(task.getId());
|
||||
update.setResultJson(updatedJson);
|
||||
update.setUpdatedAt(LocalDateTime.now());
|
||||
if (fileTaskMapper.updateById(update) != 1) {
|
||||
// B82-01:部分实体 updateById 会借 failure_category 的 ALWAYS 策略把已登记分类抹回
|
||||
// NULL——显式 wrapper 只写本方法要改的两列
|
||||
if (fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getResultJson, updatedJson)
|
||||
.set(FileTaskEntity::getUpdatedAt, LocalDateTime.now())) != 1) {
|
||||
throw new IllegalStateException("Task owner update affected no row");
|
||||
}
|
||||
log.warn("[similar-asin] task bound to current instance due to rustfs fallback taskId={} instanceId={} chunk={}",
|
||||
|
||||
+9
-1
@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.excel.ExcelStreamReader;
|
||||
import com.nanri.aiimage.config.StorageProperties;
|
||||
@@ -152,7 +153,14 @@ public class SplitRunService {
|
||||
task.setFailedFileCount(failedCount);
|
||||
task.setResultJson(JSONUtil.toJsonStr(items));
|
||||
task.setUpdatedAt(LocalDateTime.now());
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写计数/载荷/心跳四列——部分实体 updateById 会把 ALWAYS 的
|
||||
// failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount())
|
||||
.set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson())
|
||||
.set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()));
|
||||
|
||||
SplitRunVo vo = new SplitRunVo();
|
||||
vo.setTotal(request.getFiles().size());
|
||||
|
||||
+5
-1
@@ -702,7 +702,11 @@ public class WithdrawTaskService {
|
||||
task.setRequestJson(objectMapper.writeValueAsString(requestPayload));
|
||||
task.setResultJson(objectMapper.writeValueAsString(snapshots == null ? List.of() : snapshots));
|
||||
syncSnapshotTables(task, snapshots);
|
||||
fileTaskMapper.updateById(task);
|
||||
// B82-01:显式 wrapper 只写快照两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL
|
||||
fileTaskMapper.update(null, new LambdaUpdateWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getId, task.getId())
|
||||
.set(FileTaskEntity::getRequestJson, task.getRequestJson())
|
||||
.set(FileTaskEntity::getResultJson, task.getResultJson()));
|
||||
} catch (Exception ex) {
|
||||
throw new BusinessException("取款任务快照保存失败");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user