aboutsummaryrefslogtreecommitdiff
path: root/src/model/garage.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-22 15:45:45 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-22 15:45:45 +0100
commit59f61c966ae5fbc9442a5fc179ad55b7370b6892 (patch)
tree1149518e5feb0a7bc101992d8a0a3cf430cb9039 /src/model/garage.rs
parent75e591727d9cfda0133200604872a38419c178a1 (diff)
parent74d0c47f21ae2f9998a7dcbca3a27e3cc51e70b6 (diff)
downloadgarage-59f61c966ae5fbc9442a5fc179ad55b7370b6892.tar.gz
garage-59f61c966ae5fbc9442a5fc179ad55b7370b6892.zip
Merge branch 'main' into next-0.10
Diffstat (limited to 'src/model/garage.rs')
-rw-r--r--src/model/garage.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/model/garage.rs b/src/model/garage.rs
index c10d64c5..fe38a760 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -56,6 +56,9 @@ pub struct Garage {
/// Table containing api keys
pub key_table: Arc<Table<KeyTable, TableFullReplication>>,
+ /// Lock to prevent concurrent modification of buckets and access keys
+ bucket_lock: tokio::sync::Mutex<()>,
+
/// Table containing S3 objects
pub object_table: Arc<Table<ObjectTable, TableShardedReplication>>,
/// Counting table containing object counters
@@ -343,6 +346,7 @@ impl Garage {
bucket_table,
bucket_alias_table,
key_table,
+ bucket_lock: tokio::sync::Mutex::new(()),
object_table,
object_counter_table,
mpu_table,
@@ -385,6 +389,11 @@ impl Garage {
pub fn key_helper(&self) -> helper::key::KeyHelper {
helper::key::KeyHelper(self)
}
+
+ pub async fn locked_helper(&self) -> helper::locked::LockedHelper {
+ let lock = self.bucket_lock.lock().await;
+ helper::locked::LockedHelper(self, lock)
+ }
}
#[cfg(feature = "k2v")]