fix(publish): 补齐实体键唯一索引的测试覆盖与守卫消息

This commit is contained in:
toom1996
2026-09-23 10:56:08 +08:00
parent 474e1c1a64
commit e0ce81318d
4 changed files with 28 additions and 5 deletions

View File

@ -246,8 +246,10 @@ func (s *IngestService) processRunway(ctx context.Context, job model.IngestJob,
seasonCode := season.Derive(p.Year, p.CollectionType, p.Season)
reuseID, existStatus, exist, err := s.repo.RunwayEntityState(ctx, brandID, seasonCode, p.CollectionType)
if err != nil {
// 读失败绝不能当成「未命中」:实体键上没有唯一约束兜底,误判为新建会给同一实体留两行,
// 破坏「一个实体一行」的不变式。fail-closed + 退避重试。
// 读失败绝不能当成「未命中」:误判为新建会走一次注定冲突的写入——实体键唯一索引
//(2026-09-22-03)会把它拒成一次可重试的写库错误,重试时实体键已能查到该行(pending)
// 而直接跳过。但唯一索引是最后一道防线,不该靠它来替代这里的前置判断,
// 故仍 fail-closed + 退避重试,不做无谓的写尝试。
s.failOrRetry(ctx, job.ID, "entity lookup: "+err.Error())
return
}