a tool for shared writing and social publishing

get both locks in one statement

+6 -4
+6 -4
app/api/rpc/[command]/push.ts
··· 79 79 start = performance.now(); 80 80 try { 81 81 await db.transaction(async (tx) => { 82 - // Acquire transaction-scoped advisory lock on token ID 83 - // Convert token ID to a stable integer for pg_advisory_xact_lock 84 82 const tokenHash = token.id.split("").reduce((acc, char) => { 85 83 return ((acc << 5) - acc + char.charCodeAt(0)) | 0; 86 84 }, 0); ··· 89 87 .reduce((acc, char) => { 90 88 return ((acc << 5) - acc + char.charCodeAt(0)) | 0; 91 89 }, 0); 92 - await tx.execute(sql`SELECT pg_advisory_xact_lock(${tokenHash})`); 93 - await tx.execute(sql`SELECT pg_advisory_xact_lock(${clientGroupHash})`); 90 + 91 + await tx.execute(sql` 92 + SELECT 93 + pg_advisory_xact_lock(${tokenHash}), 94 + pg_advisory_xact_lock(${clientGroupHash}) 95 + `); 94 96 95 97 let clientGroupStart = performance.now(); 96 98 let clientGroup = await getClientGroup(tx, pushRequest.clientGroupID);