Skip to content

Commit 3a95422

Browse files
test(changelog): wait on this workspace's changelog lock, not any advisory waiter
1 parent 5d323e2 commit 3a95422

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎apps/sim/lib/changelog/repository.integration.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ async function publish(
6161
})
6262
}
6363

64-
/** Resolves once some session is blocked on an advisory lock. */
64+
/** Resolves once a session is blocked on this workspace's changelog lock. */
6565
async function lockWaiterAppears(): Promise<void> {
66+
const key = `changelog_release:${workspaceId}`
6667
for (;;) {
67-
const waiting =
68-
await control`SELECT 1 FROM pg_locks WHERE locktype = 'advisory' AND NOT granted`
68+
const waiting = await control`
69+
WITH k AS (SELECT hashtextextended(${key}, 0) AS h)
70+
SELECT 1 FROM pg_locks, k
71+
WHERE locktype = 'advisory' AND NOT granted AND objsubid = 1
72+
AND classid::bigint = ((k.h >> 32) & 4294967295)
73+
AND objid::bigint = (k.h & 4294967295)`
6974
if (waiting.length > 0) return
7075
await sleep(10)
7176
}

0 commit comments

Comments
 (0)