Compare commits

...

1 Commits

Author SHA1 Message Date
zheromiku 9258aa8273 fix(reconciliation): worker 在对账接线时也要注册 reconciliation.run
build / build (push) Successful in 3m5s
候选(9dddda84)实测:批次能建、入队也成功(jobs 里有 pending 行),但 worker
从不认领——worker_heartbeats.job_types 里根本没有 reconciliation.run。
原因:该 handler 注册在 workerHandlers 的测试库取件块里,而这一块在
!TEST_WEKNORA_ENABLED 时直接 return,于是只开 RECONCILIATION_ENABLED 的候选
只有 API 接线、worker 空转,批次停在 running 直到 6h 僵死回收。

把注册移到那个早退之前:只依赖 reconciliationService(租户 Key 走知识库绑定),
与旧取件/上传链路解耦。
2026-12-01 20:11:59 +08:00
+15 -11
View File
@@ -619,6 +619,21 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi
} }
handlers["source.scan.pp"] = handler.Handle handlers["source.scan.pp"] = handler.Handle
} }
// 导入对账的作业处理器只依赖对账服务本身(租户 Key 走知识库绑定),
// 与旧测试库取件/上传链路(TEST_WEKNORA_ENABLED)无关,必须在下面那个
// 早退之前注册;否则 RECONCILIATION_ENABLED=true 时候选只接线了 API,
// worker 从不认领 reconciliation.run,批次永远停在 running。
if reconciliationService != nil {
handlers["reconciliation.run"] = func(handlerCtx context.Context, job jobs.Job) error {
var payload struct {
RunID string `json:"run_id"`
}
if err := json.Unmarshal(job.Payload, &payload); err != nil || payload.RunID == "" {
return jobs.Permanent(jobs.ErrCodeHandlerFallback, errors.New("invalid reconciliation run payload"))
}
return reconciliationService.ExecuteRun(handlerCtx, payload.RunID)
}
}
if !config.TestWeKnoraEnabled || !config.LibraryWorkerRole.ExecutesSourceWork() { if !config.TestWeKnoraEnabled || !config.LibraryWorkerRole.ExecutesSourceWork() {
return handlers, nil return handlers, nil
} }
@@ -695,17 +710,6 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi
handlers["test.poll"] = poll.Handle handlers["test.poll"] = poll.Handle
handlers["test.validate"] = validate.Handle handlers["test.validate"] = validate.Handle
handlers["test.remove"] = remove.Handle handlers["test.remove"] = remove.Handle
if reconciliationService != nil {
handlers["reconciliation.run"] = func(handlerCtx context.Context, job jobs.Job) error {
var payload struct {
RunID string `json:"run_id"`
}
if err := json.Unmarshal(job.Payload, &payload); err != nil || payload.RunID == "" {
return jobs.Permanent(jobs.ErrCodeHandlerFallback, errors.New("invalid reconciliation run payload"))
}
return reconciliationService.ExecuteRun(handlerCtx, payload.RunID)
}
}
return handlers, nil return handlers, nil
} }