From f4b3f4c4c845db1d1dd575d97b3ce0cd6ef807e7 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 19:12:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(reconciliation):=20=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=89=B9=E5=8D=A0=E4=BD=8D=E8=AF=AD=E5=8F=A5=E4=BF=AE=2042P08?= =?UTF-8?q?=EF=BC=8C=E7=9C=9F=E5=AE=9E=20PG=20=E4=B8=8A=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=20claim=20=E5=8D=B3=E5=8F=AF=E5=BB=BA=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 白盒在真实 PostgreSQL 上跑新集成用例时,ClaimScheduledReconciliationRun 首次 claim 就报 inconsistent types deduced for parameter $2 (42P08):同一个 KB id 既进 INSERT 目标列(varchar(255))又参与子查询比较(varchar),参数被推断成两种 类型。把比较侧改成独立参数 $7,并在语句上方写明原因。 存量缺陷,改动前同样报错(reconciliation_schedules 一直建不出批次,C-105 无法通过)。 验证: - TEST_DB 指向一次性 PostgreSQL 16,TestScheduledReconciliationClaimsOncePerDayAfterFailure 通过 (首日占位一次;失败后同日不再建;次日可建) - TestReconciliationRunUniquenessStaleAndRetentionIntegration 同库通过 - make verify 17 项 = 16 success + identity skipped --- internal/platform/postgres/reconciliation_store.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/platform/postgres/reconciliation_store.go b/internal/platform/postgres/reconciliation_store.go index ba5ac3a..c4abc61 100644 --- a/internal/platform/postgres/reconciliation_store.go +++ b/internal/platform/postgres/reconciliation_store.go @@ -72,16 +72,19 @@ func (s *Store) ClaimScheduledReconciliationRun(ctx context.Context, run governa if err != nil { return governance.ReconciliationRun{}, false, err } + // The KB id is passed twice on purpose: PostgreSQL deduces varchar(255) for + // the INSERT target and varchar for the comparison, and one parameter used in + // both positions fails with 42P08 "inconsistent types deduced". row := s.db.QueryRow(ctx, `INSERT INTO reconciliation_runs (id,test_kb_id,state,trigger,started_at,counts,created_at) SELECT $1,$2,'running','schedule',$3,$4::jsonb,$5 WHERE NOT EXISTS( SELECT 1 FROM reconciliation_runs - WHERE test_kb_id=$2 AND trigger='schedule' AND state IN ('running','succeeded','failed') AND started_at >= $6 + WHERE test_kb_id=$7 AND trigger='schedule' AND state IN ('running','succeeded','failed') AND started_at >= $6 ) ON CONFLICT DO NOTHING RETURNING `+reconciliationRunColumns, - run.ID, run.KBID, run.StartedAt, counts, now, since) + run.ID, run.KBID, run.StartedAt, counts, now, since, run.KBID) claimed, err := scanReconciliationRun(row) if errors.Is(err, pgx.ErrNoRows) { return governance.ReconciliationRun{}, false, nil -- 2.52.0