a tool for shared writing and social publishing

use an advisory lock on token id on push

+7
+7
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 + const tokenHash = token.id.split("").reduce((acc, char) => { 85 + return ((acc << 5) - acc + char.charCodeAt(0)) | 0; 86 + }, 0); 87 + await tx.execute(sql`SELECT pg_advisory_xact_lock(${tokenHash})`); 88 + 82 89 let clientGroupStart = performance.now(); 83 90 let clientGroup = await getClientGroup(tx, pushRequest.clientGroupID); 84 91 timeGettingClientGroup = performance.now() - clientGroupStart;