mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
Repair stale large channel roster snapshots (#6251)
## Summary - detect relay-authored NIP-29 kind 39002 roster snapshots truncated by the former 1,000-member query cap and repair stale large rosters during relay startup - serialize canonical roster capture and replacement with membership writes, preserving tenant, channel, signer, pubkey, and role boundaries through mixed-version deployments - install migration 0032's fail-closed roster fence on the partitioned events table and verify its catalog shape plus behavior before opening relay listeners ## Rollout Migration 0032 is a hard schema-before-code compatibility boundary. Apply migrations before rolling this relay version. Startup refuses to open listeners when the parent/partition triggers are missing, disabled, mis-shaped, or behaviorally inert. For large installations, prefer `buzz-admin migrate` and monitor lock acquisition as documented in the chart README. ## Validation Exact head: `bcbba271f54bc0046a6683007e5a2b70403a11d5` - rebased onto `569308c23c9c2bf620dd3a9a5e4baecbcfa22e16`; the nine-file feature patch is byte-identical to pre-rebase head `be8ea0084f4d4c78c7c2550baad4399e4df8ce73` - pre-push hook passed at exact head: branch-skew, file-size, full Rust unit suite, Desktop Tauri clippy, and Desktop Tauri tests - `cargo fmt --all -- --check` - `cargo test -p buzz-relay group_members_snapshot_keeps_members_past_one_thousand -- --nocapture` - focused CI-mode Playwright regression: `selected relay agents revoked after the invite prompt cause no side effects` passed at exact head - prior exact-patch validation: `large_roster_reconciliation_candidates_respect_snapshot_count_and_signer`, mixed-writer locking/rollback, migration admission, partition trigger coverage, and desired-schema parity regressions ## Review Independent DB/relay review found no blocking issues in the exact feature patch. The concurrency fence holds the established replacement and membership locks on one transaction/connection through replacement; failures roll back both soft-delete and insert. Reconciliation remains tenant/channel/signer scoped and validates exact normalized pubkey-plus-role membership. The prior red Desktop shard was unrelated to this backend-only diff: its mocked mention test exercises no relay, database, or migration path. It reproduced as a timing flake on the old head, passed on retry/base, and now passes locally after rebasing onto current main. --------- Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -16,12 +16,12 @@ BEGIN
|
||||
) THEN
|
||||
-- pgschema may copy parent triggers onto standalone children. Drop
|
||||
-- those copies before ATTACH; PostgreSQL recreates inherited parent
|
||||
-- triggers while attaching and rejects same-named child triggers
|
||||
-- (both the push-match trigger and the replica-fence floor guard).
|
||||
-- triggers while attaching and rejects same-named child triggers.
|
||||
DROP TRIGGER IF EXISTS events_enqueue_push_match ON events_p_past;
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p_past;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p_past;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p_past;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p_past;
|
||||
ALTER TABLE events ATTACH PARTITION events_p_past
|
||||
FOR VALUES FROM (MINVALUE) TO ('2026-01-01');
|
||||
END IF;
|
||||
@@ -35,6 +35,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_01;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_01;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_01;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_01;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_01
|
||||
FOR VALUES FROM ('2026-01-01') TO ('2026-02-01');
|
||||
END IF;
|
||||
@@ -48,6 +49,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_02;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_02;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_02;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_02;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_02
|
||||
FOR VALUES FROM ('2026-02-01') TO ('2026-03-01');
|
||||
END IF;
|
||||
@@ -61,6 +63,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_03;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_03;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_03;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_03;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_03
|
||||
FOR VALUES FROM ('2026-03-01') TO ('2026-04-01');
|
||||
END IF;
|
||||
@@ -74,6 +77,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_04;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_04;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_04;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_04;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_04
|
||||
FOR VALUES FROM ('2026-04-01') TO ('2026-05-01');
|
||||
END IF;
|
||||
@@ -87,6 +91,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_05;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_05;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_05;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_05;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_05
|
||||
FOR VALUES FROM ('2026-05-01') TO ('2026-06-01');
|
||||
END IF;
|
||||
@@ -100,6 +105,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p2026_06;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p2026_06;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p2026_06;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p2026_06;
|
||||
ALTER TABLE events ATTACH PARTITION events_p2026_06
|
||||
FOR VALUES FROM ('2026-06-01') TO ('2026-07-01');
|
||||
END IF;
|
||||
@@ -113,6 +119,7 @@ BEGIN
|
||||
DROP TRIGGER IF EXISTS events_refresh_channel_ttl ON events_p_future;
|
||||
DROP TRIGGER IF EXISTS events_created_at_floor ON events_p_future;
|
||||
DROP TRIGGER IF EXISTS community_write_fence_events ON events_p_future;
|
||||
DROP TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot ON events_p_future;
|
||||
ALTER TABLE events ATTACH PARTITION events_p_future
|
||||
FOR VALUES FROM ('2026-07-01') TO (MAXVALUE);
|
||||
END IF;
|
||||
|
||||
Reference in New Issue
Block a user