Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding the pg_lock for the token #293

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/stores/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ impl ClientStore for sqlx::PgPool {

let mut transaction = self.begin().await?;

// Statement for locking to prevent an issue #230
// Statement for locking based on the client id to prevent an issue #230
sqlx::query("SELECT pg_advisory_xact_lock(abs(hashtext($1::text)))")
.bind(id)
.execute(&mut transaction)
.await?;

// Statement for locking based on the token to prevent an issue #292
sqlx::query("SELECT pg_advisory_xact_lock(abs(hashtext($1::text)))")
.bind(client.token.clone())
.execute(&mut transaction)
.await?;

sqlx::query("DELETE FROM public.clients WHERE id = $1 OR device_token = $2")
.bind(id)
.bind(client.token.clone())
Expand Down
Loading