File tree Expand file tree Collapse file tree
apps/sim/lib/mothership/async-runs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import {
2727 sql ,
2828} from 'drizzle-orm'
2929import { type ResourceOwner , resourceScopeFromOwner } from '@/lib/core/resource-scope'
30+ import { acquireAdvisoryXactLock } from '@/lib/db/advisory-locks'
3031import type { SessionProcessIdentity } from '@/lib/execution/remote-sandbox/session-process'
3132import { AsyncToolCallOwnershipError } from '@/lib/mothership/async-runs/errors'
3233import {
@@ -132,7 +133,7 @@ export async function withRunAdmissionLock<T>(
132133 return db . transaction ( async ( tx ) => {
133134 await tx . execute ( sql `SET LOCAL statement_timeout = '10s'` )
134135 const key = JSON . stringify ( [ 'copilot-run-admission' , userId , streamId ] )
135- await tx . execute ( sql `SELECT pg_advisory_xact_lock(hashtextextended( ${ key } , 0))` )
136+ await acquireAdvisoryXactLock ( tx , 'copilot_run_admission' , key )
136137 return action ( tx )
137138 } )
138139}
You can’t perform that action at this time.
0 commit comments