fix(gpu): count backfill enqueues via RETURNING, not rowcount
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m25s

result.rowcount is unreliable for INSERT…SELECT (returned -1), failing the
idempotency assert. Use .returning(GpuJob.id) and count the rows. (run 1652)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
This commit is contained in:
2026-06-29 11:39:11 -04:00
parent f247f9247c
commit 558d965a1c
+7 -6
View File
@@ -760,10 +760,11 @@ def enqueue_gpu_backfill(task_name: str) -> int:
sel = sa_select(
ImageRecord.id, literal(task_name), literal("pending")
).where(~already)
result = session.execute(
insert(GpuJob).from_select(
["image_record_id", "task", "status"], sel
)
)
# RETURNING + count: result.rowcount is unreliable for INSERT…SELECT.
rows = session.execute(
insert(GpuJob)
.from_select(["image_record_id", "task", "status"], sel)
.returning(GpuJob.id)
).fetchall()
session.commit()
return result.rowcount or 0
return len(rows)