File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -177,12 +177,24 @@ export class KnexAdapter implements Adapter {
177177 }
178178
179179 // Update job to active status
180- await trx ( this . #jobsTable) . where ( 'id' , job . id ) . where ( 'queue' , queue ) . update ( {
180+ // For SQLite (no SKIP LOCKED), add status='pending' guard to prevent double-claim
181+ const updateQuery = trx ( this . #jobsTable) . where ( 'id' , job . id ) . where ( 'queue' , queue )
182+
183+ if ( ! this . #supportsSkipLocked( ) ) {
184+ updateQuery . where ( 'status' , 'pending' )
185+ }
186+
187+ const updated = await updateQuery . update ( {
181188 status : 'active' ,
182189 worker_id : this . #workerId,
183190 acquired_at : now ,
184191 } )
185192
193+ // Another worker already claimed this job
194+ if ( updated === 0 ) {
195+ return null
196+ }
197+
186198 const jobData : JobData = JSON . parse ( job . data )
187199
188200 return {
You can’t perform that action at this time.
0 commit comments