@@ -235,7 +235,11 @@ export class BackendPostgres implements Backend {
235235
236236 private async acquireConcurrencyCreateLock (
237237 pg : Postgres ,
238- params : { workflowName : string ; version : string | null ; key : string } ,
238+ params : {
239+ workflowName : string ;
240+ version : string | null ;
241+ key : string | null ;
242+ } ,
239243 ) : Promise < void > {
240244 // Intentionally uses a different lock payload shape than claim-time locks.
241245 // Create-time lock serializes concurrent creates in the bucket, while
@@ -277,7 +281,7 @@ export class BackendPostgres implements Backend {
277281 params : {
278282 workflowName : string ;
279283 version : string | null ;
280- key : string ;
284+ key : string | null ;
281285 limit : number ;
282286 } ,
283287 ) : Promise < void > {
@@ -288,7 +292,7 @@ export class BackendPostgres implements Backend {
288292 WHERE "namespace_id" = ${ this . namespaceId }
289293 AND "workflow_name" = ${ params . workflowName }
290294 AND "version" IS NOT DISTINCT FROM ${ params . version }
291- AND "concurrency_key" = ${ params . key }
295+ AND "concurrency_key" IS NOT DISTINCT FROM ${ params . key }
292296 -- Sleeping runs are excluded so long sleeps do not pin historical
293297 -- limits and block new run creation after config changes.
294298 AND "status" IN ('pending', 'running')
@@ -418,8 +422,7 @@ export class BackendPostgres implements Backend {
418422 AND wr."available_at" <= NOW()
419423 AND (wr."deadline_at" IS NULL OR wr."deadline_at" > NOW())
420424 AND (
421- wr."concurrency_key" IS NULL
422- OR wr."concurrency_limit" IS NULL
425+ wr."concurrency_limit" IS NULL
423426 OR CASE
424427 -- cspell:ignore xact hashtextextended
425428 -- Serialize constrained claims per bucket. pg_try_advisory lock
@@ -447,7 +450,7 @@ export class BackendPostgres implements Backend {
447450 WHERE active."namespace_id" = wr."namespace_id"
448451 AND active."workflow_name" = wr."workflow_name"
449452 AND active."version" IS NOT DISTINCT FROM wr."version"
450- AND active."concurrency_key" = wr."concurrency_key"
453+ AND active."concurrency_key" IS NOT DISTINCT FROM wr."concurrency_key"
451454 AND active."status" = 'running'
452455 -- Candidates require available_at <= NOW(); active leased runs
453456 -- require available_at > NOW(). Keep explicit self-exclusion
0 commit comments