Skip to content

Commit 25138bf

Browse files
docs(db): keep membership lock rationale with owner
Signed-off-by: tornquist <[email protected]>
1 parent 81c3d09 commit 25138bf

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,6 @@ pub async fn set_canvas(
328328
Ok(())
329329
}
330330

331-
/// Namespace for the per-channel membership advisory lock. Serializes the
332-
/// role-authorization + last-owner-count + write sequences in [`add_member`]
333-
/// and [`remove_member`] against each other.
334-
///
335-
/// Both functions read an owner COUNT and then write a *different* row than the
336-
/// one they counted, so `READ COMMITTED` snapshot isolation alone permits two
337-
/// concurrent demotions (or a demotion racing a removal) to each observe two
338-
/// owners, each pass, and together leave zero — the exact governance loss the
339-
/// guards exist to prevent. An advisory key rather than `SELECT ... FOR UPDATE`
340-
/// on the channel row: membership is its own contention domain and must not
341-
/// serialize against unrelated channel metadata writers (`update_channel`,
342-
/// `set_topic`, the TTL transition). Distinct key domain from
343-
/// `buzz_channel_ttl:`.
344331
/// Lists channels in a community, optionally filtered by visibility string.
345332
pub async fn list_channels(
346333
pool: &PgPool,

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ pub struct MemberRecord {
3232
pub removed_at: Option<DateTime<Utc>>,
3333
}
3434

35+
/// Namespace for the per-channel membership advisory lock. Serializes the
36+
/// role-authorization + last-owner-count + write sequences in [`add_member`]
37+
/// and [`remove_member`] against each other.
38+
///
39+
/// Both functions read an owner COUNT and then write a *different* row than the
40+
/// one they counted, so `READ COMMITTED` snapshot isolation alone permits two
41+
/// concurrent demotions (or a demotion racing a removal) to each observe two
42+
/// owners, each pass, and together leave zero — the exact governance loss the
43+
/// guards exist to prevent. An advisory key rather than `SELECT ... FOR UPDATE`
44+
/// on the channel row: membership is its own contention domain and must not
45+
/// serialize against unrelated channel metadata writers (`update_channel`,
46+
/// `set_topic`, the TTL transition). Distinct key domain from
47+
/// `buzz_channel_ttl:`.
3548
const CHANNEL_MEMBERSHIP_LOCK_NAMESPACE: &str = "buzz_channel_membership:";
3649

3750
/// Verify that migration 0032's roster fence is active on the partitioned

0 commit comments

Comments
 (0)