mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(coderd/database): prevent AcquireProvisionerJob from grabbing canceled jobs (#21852)
The AcquireProvisionerJob query only checked started_at IS NULL, allowing it to acquire jobs that were canceled while pending (which have completed_at set but started_at still NULL). Added completed_at IS NULL check to the query to prevent this. Also fixed JobCompleteBuilder.Do() in dbfake to set started_at when completing jobs to match production behavior. Fixes coder/internal#1323
This commit is contained in:
@@ -19,6 +19,7 @@ WHERE
|
||||
provisioner_jobs AS potential_job
|
||||
WHERE
|
||||
potential_job.started_at IS NULL
|
||||
AND potential_job.completed_at IS NULL
|
||||
AND potential_job.organization_id = @organization_id
|
||||
-- Ensure the caller has the correct provisioner.
|
||||
AND potential_job.provisioner = ANY(@types :: provisioner_type [ ])
|
||||
|
||||
Reference in New Issue
Block a user