fix: clear stale error when dequeuing work tasks
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
When a task is retried (dequeued again after failure), the previous error message was persisting in the work_queue table. This caused the API to return confusing responses with status="running" but also containing an error message from the previous attempt. Now clears error and completed_at when claiming a task, matching the fix already applied to build_audit.UpdateStatus. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9833725f31
commit
59aa173384
@ -60,9 +60,11 @@ func (r *WorkQueueRepository) Dequeue(ctx context.Context, workerID string) (*do
|
||||
var resultJSON []byte
|
||||
var errorMsg sql.NullString
|
||||
|
||||
// Clear stale error/completed_at when claiming for execution or retry.
|
||||
// This prevents the API from returning confusing "running" status with stale error messages.
|
||||
err := r.db.QueryRowContext(ctx, `
|
||||
UPDATE work_queue
|
||||
SET status = 'running', worker_id = $1, started_at = NOW()
|
||||
SET status = 'running', worker_id = $1, started_at = NOW(), error = NULL, completed_at = NULL
|
||||
WHERE id = (
|
||||
SELECT id FROM work_queue
|
||||
WHERE status = 'pending'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user