修复导入重试的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m53s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m53s
This commit is contained in:
@@ -85,7 +85,18 @@ func (h *DeviceImportHandler) HandleDeviceImport(ctx context.Context, task *asyn
|
||||
return asynq.SkipRetry
|
||||
}
|
||||
|
||||
if importTask.Status != model.ImportTaskStatusPending {
|
||||
switch importTask.Status {
|
||||
case model.ImportTaskStatusPending:
|
||||
// 正常首次处理
|
||||
case model.ImportTaskStatusProcessing:
|
||||
// 上次 worker 中途中断(重启/崩溃),重置计数重新处理
|
||||
// 已入库的设备会被 ExistsByDeviceNoBatch 识别为 skip,不会重复写入
|
||||
h.logger.Warn("检测到导入任务上次处理中途中断,重置进度重新处理",
|
||||
zap.Uint("task_id", payload.TaskID),
|
||||
)
|
||||
h.importTaskStore.UpdateProgress(ctx, importTask.ID, 0, 0, 0)
|
||||
default:
|
||||
// 已完成或失败,不重复处理
|
||||
h.logger.Info("导入任务已处理,跳过",
|
||||
zap.Uint("task_id", payload.TaskID),
|
||||
zap.Int("status", importTask.Status),
|
||||
|
||||
@@ -92,7 +92,18 @@ func (h *IotCardImportHandler) HandleIotCardImport(ctx context.Context, task *as
|
||||
return asynq.SkipRetry
|
||||
}
|
||||
|
||||
if importTask.Status != model.ImportTaskStatusPending {
|
||||
switch importTask.Status {
|
||||
case model.ImportTaskStatusPending:
|
||||
// 正常首次处理
|
||||
case model.ImportTaskStatusProcessing:
|
||||
// 上次 worker 中途中断(重启/崩溃),重置计数重新处理
|
||||
// 已入库的卡会被 ExistsByICCIDBatch 识别为 skip,不会重复写入
|
||||
h.logger.Warn("检测到导入任务上次处理中途中断,重置进度重新处理",
|
||||
zap.Uint("task_id", payload.TaskID),
|
||||
)
|
||||
h.importTaskStore.UpdateProgress(ctx, importTask.ID, 0, 0, 0)
|
||||
default:
|
||||
// 已完成或失败,不重复处理
|
||||
h.logger.Info("导入任务已处理,跳过",
|
||||
zap.Uint("task_id", payload.TaskID),
|
||||
zap.Int("status", importTask.Status),
|
||||
|
||||
Reference in New Issue
Block a user