tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
get both locks in one statement
awarm.space
6 months ago
9471d28f
65a184c6
+6
-4
1 changed file
expand all
collapse all
unified
split
app
api
rpc
[command]
push.ts
+6
-4
app/api/rpc/[command]/push.ts
···
79
79
start = performance.now();
80
80
try {
81
81
await db.transaction(async (tx) => {
82
82
-
// Acquire transaction-scoped advisory lock on token ID
83
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
92
-
await tx.execute(sql`SELECT pg_advisory_xact_lock(${tokenHash})`);
93
93
-
await tx.execute(sql`SELECT pg_advisory_xact_lock(${clientGroupHash})`);
90
90
+
91
91
+
await tx.execute(sql`
92
92
+
SELECT
93
93
+
pg_advisory_xact_lock(${tokenHash}),
94
94
+
pg_advisory_xact_lock(${clientGroupHash})
95
95
+
`);
94
96
95
97
let clientGroupStart = performance.now();
96
98
let clientGroup = await getClientGroup(tx, pushRequest.clientGroupID);