fix(coderd/database): prevent AcquireProvisionerJob from grabbing canceled jobs by mafredri · Pull Request #21852 · coder/coder
…celed jobs 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, ensuring test provisioner daemons don't attempt to acquire already-completed fake jobs. Fixes coder/internal#1323
Adds a test case to TestAcquireProvisionerJob that verifies the query correctly skips jobs that were canceled while pending (started_at is NULL but completed_at is set).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters