Skip to content

Commit 4d823da

Browse files
authored
feat(relay): inventory unreachable Git objects (#2264)
1 parent 5216f3f commit 4d823da

13 files changed

Lines changed: 700 additions & 19 deletions

File tree

‎.env.example‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ RELAY_URL=ws://localhost:3000
7575
# BUZZ_GIT_PACK_CACHE_PATH=./repos/.pack-cache
7676
# BUZZ_GIT_PACK_CACHE_MAX_BYTES=5368709120
7777
# BUZZ_GIT_PACK_CACHE_MAX_CONCURRENT_POPULATIONS=2
78+
# Deployment-global dry-run inventory for future physical object-store GC.
79+
# No objects are deleted. Disabled by default.
80+
# BUZZ_GIT_GC_ENABLED=false
81+
# BUZZ_GIT_GC_INTERVAL_SECS=3600
82+
# BUZZ_GIT_GC_MAX_POINTERS=10000
83+
# BUZZ_GIT_GC_MAX_OBJECTS_PER_PREFIX=10000
84+
# BUZZ_GIT_GC_MAX_MANIFEST_BYTES_PER_SCAN=536870912
85+
# BUZZ_GIT_GC_SCAN_TIMEOUT_SECS=300
7886

7987
# -----------------------------------------------------------------------------
8088
# Media Upload Admission

‎bin/.helm-3.16.4.pkg‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

‎bin/helm‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.helm-3.16.4.pkg

‎crates/buzz-db/src/lib.rs‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,16 @@ pub struct DbPoolStats {
198198
pub max: u32,
199199
}
200200

201-
/// Owns the detached Postgres session holding the relay usage-metrics advisory lock.
201+
/// Owns a detached Postgres session holding a relay advisory leader lock.
202202
///
203203
/// The connection deliberately does not return to the main pool: session advisory
204204
/// locks must remain bound to this exact physical connection, and the poller
205205
/// pings it before each leader-only collection tick.
206-
pub struct UsageMetricsLeader {
206+
pub struct AdvisoryLockLeader {
207207
connection: PgConnection,
208208
}
209209

210-
impl UsageMetricsLeader {
210+
impl AdvisoryLockLeader {
211211
/// Returns whether the lock-owning session is still reachable.
212212
///
213213
/// Bounded to 5 seconds — a blackholed connection (no RST) would otherwise
@@ -508,23 +508,20 @@ impl Db {
508508
})
509509
}
510510

511-
/// Try to acquire the detached session advisory lock for relay usage metrics.
511+
/// Try to acquire a detached session advisory lock for singleton relay work.
512512
///
513513
/// The returned guard owns the exact connection that acquired the lock. It is
514514
/// detached from the shared pool so a stable leader neither returns a locked
515515
/// session to other callers nor permanently consumes a pool slot. Dropping the
516516
/// guard closes the connection and releases the session-scoped lock.
517-
pub async fn try_lock_usage_metrics(
518-
&self,
519-
lock_key: i64,
520-
) -> Result<Option<UsageMetricsLeader>> {
517+
pub async fn try_advisory_lock(&self, lock_key: i64) -> Result<Option<AdvisoryLockLeader>> {
521518
let mut connection = self.pool.acquire().await?;
522519
let acquired = sqlx::query_scalar::<_, bool>("SELECT pg_try_advisory_lock($1)")
523520
.bind(lock_key)
524521
.fetch_one(&mut *connection)
525522
.await?;
526523
if acquired {
527-
Ok(Some(UsageMetricsLeader {
524+
Ok(Some(AdvisoryLockLeader {
528525
connection: connection.detach(),
529526
}))
530527
} else {
@@ -4663,14 +4660,14 @@ mod tests {
46634660
let key = 0x4255_5A5A_4D45_5452;
46644661

46654662
let mut leader = first
4666-
.try_lock_usage_metrics(key)
4663+
.try_advisory_lock(key)
46674664
.await
46684665
.expect("first lock attempt")
46694666
.expect("first database handle becomes leader");
46704667
assert!(leader.is_live().await, "lock owner remains reachable");
46714668
assert!(
46724669
second
4673-
.try_lock_usage_metrics(key)
4670+
.try_advisory_lock(key)
46744671
.await
46754672
.expect("second lock attempt")
46764673
.is_none(),
@@ -4680,7 +4677,7 @@ mod tests {
46804677
drop(leader);
46814678
assert!(
46824679
second
4683-
.try_lock_usage_metrics(key)
4680+
.try_advisory_lock(key)
46844681
.await
46854682
.expect("lock attempt after leader drop")
46864683
.is_some(),

0 commit comments

Comments
 (0)