From 9258aa82735fbec77635e0cc0229fd11cde2776f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhero=20=26=20=E5=8A=A9=E7=90=86?= <836283459@qq.com> Date: Tue, 1 Dec 2026 20:11:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(reconciliation):=20worker=20=E5=9C=A8?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E6=8E=A5=E7=BA=BF=E6=97=B6=E4=B9=9F=E8=A6=81?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=20reconciliation.run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 候选(9dddda84)实测:批次能建、入队也成功(jobs 里有 pending 行),但 worker 从不认领——worker_heartbeats.job_types 里根本没有 reconciliation.run。 原因:该 handler 注册在 workerHandlers 的测试库取件块里,而这一块在 !TEST_WEKNORA_ENABLED 时直接 return,于是只开 RECONCILIATION_ENABLED 的候选 只有 API 接线、worker 空转,批次停在 running 直到 6h 僵死回收。 把注册移到那个早退之前:只依赖 reconciliationService(租户 Key 走知识库绑定), 与旧取件/上传链路解耦。 --- cmd/worker/main.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 374ed0e..8ca9964 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -619,6 +619,21 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi } 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() { return handlers, nil } @@ -695,17 +710,6 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi handlers["test.poll"] = poll.Handle handlers["test.validate"] = validate.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 } -- 2.52.0