fix(gpu): count backfill enqueues via RETURNING, not rowcount
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:
@@ -760,10 +760,11 @@ def enqueue_gpu_backfill(task_name: str) -> int:
|
|||||||
sel = sa_select(
|
sel = sa_select(
|
||||||
ImageRecord.id, literal(task_name), literal("pending")
|
ImageRecord.id, literal(task_name), literal("pending")
|
||||||
).where(~already)
|
).where(~already)
|
||||||
result = session.execute(
|
# RETURNING + count: result.rowcount is unreliable for INSERT…SELECT.
|
||||||
insert(GpuJob).from_select(
|
rows = session.execute(
|
||||||
["image_record_id", "task", "status"], sel
|
insert(GpuJob)
|
||||||
)
|
.from_select(["image_record_id", "task", "status"], sel)
|
||||||
)
|
.returning(GpuJob.id)
|
||||||
|
).fetchall()
|
||||||
session.commit()
|
session.commit()
|
||||||
return result.rowcount or 0
|
return len(rows)
|
||||||
|
|||||||
Reference in New Issue
Block a user