fix(reconciliation): 定时批占位语句修 42P08(CYWL-34) #47
@@ -72,16 +72,19 @@ func (s *Store) ClaimScheduledReconciliationRun(ctx context.Context, run governa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return governance.ReconciliationRun{}, false, err
|
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
|
row := s.db.QueryRow(ctx, `INSERT INTO reconciliation_runs
|
||||||
(id,test_kb_id,state,trigger,started_at,counts,created_at)
|
(id,test_kb_id,state,trigger,started_at,counts,created_at)
|
||||||
SELECT $1,$2,'running','schedule',$3,$4::jsonb,$5
|
SELECT $1,$2,'running','schedule',$3,$4::jsonb,$5
|
||||||
WHERE NOT EXISTS(
|
WHERE NOT EXISTS(
|
||||||
SELECT 1 FROM reconciliation_runs
|
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
|
ON CONFLICT DO NOTHING
|
||||||
RETURNING `+reconciliationRunColumns,
|
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)
|
claimed, err := scanReconciliationRun(row)
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
return governance.ReconciliationRun{}, false, nil
|
return governance.ReconciliationRun{}, false, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user