fix(reconciliation): 对账任务入队 id 超长导致每批 queue_unavailable(CYWL-34) #48

Merged
zheromiku merged 1 commits from fix/t6-enqueue-job-id into main 2026-12-01 19:49:53 +08:00
Owner

候选库实测:19:37 起所有 reconciliation_runs 都是 failed / error_code=queue_unavailable,没有任何一批进入 worker。

根因(存量):enqueueRun 用 "job-" + run_id 作为 jobs.id,而 jobs.id 是 VARCHAR(36);run_id 本身已是 36 字符(rec- + 32 位 hex),拼出来 40 字符 → INSERT 必然失败 → 批次在 claim 之后立刻判 failed。

修复:job 自带 job- + 32 位 hex 的 id(正好 36 字符),幂等仍由唯一 idempotency_key(reconciliation-run:<run_id>)保证。

新增单测 TestCreateRunEnqueuesJobWithinJobIDLimit:CreateRun 的入队请求 id 必须恰好 36 字符,type/idempotency_key/payload 与 run 一致。

验证:go test ./internal/reconciliation/ 通过;make verify 17 项 = 16 success + identity skipped。契约未动。

候选库实测:19:37 起所有 `reconciliation_runs` 都是 `failed` / `error_code=queue_unavailable`,没有任何一批进入 worker。 根因(存量):`enqueueRun` 用 `"job-" + run_id` 作为 `jobs.id`,而 `jobs.id` 是 `VARCHAR(36)`;`run_id` 本身已是 36 字符(`rec-` + 32 位 hex),拼出来 40 字符 → INSERT 必然失败 → 批次在 claim 之后立刻判 failed。 修复:job 自带 `job-` + 32 位 hex 的 id(正好 36 字符),幂等仍由唯一 `idempotency_key`(`reconciliation-run:<run_id>`)保证。 新增单测 `TestCreateRunEnqueuesJobWithinJobIDLimit`:`CreateRun` 的入队请求 id 必须恰好 36 字符,type/idempotency_key/payload 与 run 一致。 验证:`go test ./internal/reconciliation/` 通过;`make verify` 17 项 = 16 success + identity skipped。契约未动。
zheromiku added 1 commit 2026-12-01 19:47:15 +08:00
enqueueRun 用 "job-" + run_id 当 jobs.id,而 jobs.id 是 VARCHAR(36);run_id 本身
已是 36 字符(rec- + 32 位 hex),拼出 40 字符,INSERT 必然失败,批次在 claim 之后
立刻被记成 failed/queue_unavailable——候选库里 19:37 起所有批次都是这个状态,C-101
起的用例全部无法开始。

改为 job 自带 "job-"+32 位 hex 的 id(36 字符),幂等仍由唯一 idempotency_key
(reconciliation-run:<run_id>)保证。补单测:CreateRun 入队请求 id 必须正好 36 字符、
type/idempotency_key/payload 与 run 一致。

验证:go test ./internal/reconciliation/ 通过;make verify 17 项 = 16 success + identity skipped。
zheromiku merged commit 9dddda8491 into main 2026-12-01 19:49:53 +08:00
Sign in to join this conversation.