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(
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user