Skip to content

Commit b233178

Browse files
committed
improvement(db): tag the copilot run admission advisory lock
1 parent 2c046fe commit b233178

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎apps/sim/lib/mothership/async-runs/repository.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
sql,
2828
} from 'drizzle-orm'
2929
import { type ResourceOwner, resourceScopeFromOwner } from '@/lib/core/resource-scope'
30+
import { acquireAdvisoryXactLock } from '@/lib/db/advisory-locks'
3031
import type { SessionProcessIdentity } from '@/lib/execution/remote-sandbox/session-process'
3132
import { AsyncToolCallOwnershipError } from '@/lib/mothership/async-runs/errors'
3233
import {
@@ -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
}

0 commit comments

Comments
 (0)