Skip to content

Commit

Permalink
Fix locking timeout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Dec 27, 2024
1 parent c86c98d commit 82393f2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions apps/labrinth/src/database/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,12 @@ impl RedisPool {

fetch_ids.iter().for_each(|key| {
pipe.atomic().set_options(
format!("{}_{namespace}:{}/lock", self.meta_namespace, key),
// We store locks in lowercase because they are case insensitive
format!(
"{}_{namespace}:{}/lock",
self.meta_namespace,
key.to_lowercase()
),
100,
SetOptions::default()
.get(true)
Expand Down Expand Up @@ -395,7 +400,9 @@ impl RedisPool {

pipe.atomic().del(format!(
"{}_{namespace}:{}/lock",
self.meta_namespace, actual_slug
// Locks are stored in lowercase
self.meta_namespace,
actual_slug.to_lowercase()
));
}
}
Expand All @@ -408,8 +415,10 @@ impl RedisPool {
ids.remove(&base62);

pipe.atomic().del(format!(
"{}_{namespace}:{base62}/lock",
self.meta_namespace
"{}_{namespace}:{}/lock",
self.meta_namespace,
// Locks are stored in lowercase
base62.to_lowercase()
));
}

Expand Down Expand Up @@ -451,7 +460,8 @@ impl RedisPool {
format!(
"{}_{namespace}:{}/lock",
self.meta_namespace,
x.key()
// We lowercase key because locks are stored in lowercase
x.key().to_lowercase()
)
})
.collect::<Vec<_>>(),
Expand Down

0 comments on commit 82393f2

Please sign in to comment.