Skip to content

fix(db): skip tombstoned communities in community_hosts enumeration - #7630

Open
olympusbuildz wants to merge 1 commit into
block:mainfrom
olympusbuildz:fix/7558-nip43-skip-tombstoned-communities
Open

olympusbuildz wants to merge 1 commit into
block:mainfrom
olympusbuildz:fix/7558-nip43-skip-tombstoned-communities

Conversation

@olympusbuildz

Copy link
Copy Markdown

The community_hosts_with_operation query selected every row from communities with no deletion_state filter. After a whole-community deletion completes, the row remains as a tombstone (deletion_state = 'tombstone') while awaiting physical retention expiry — this is by design.

Both the NIP-43 maintenance sweep (usage_community_hosts) and the push worker pass these ids to reconcile_nip43_membership_snapshots, which calls publish_nip43_membership_list on each. The community write fence rejects the write, producing a WARN log ("NIP-43 membership reconciliation failed") every ~60s indefinitely — exactly the symptom reported in #7558.

Root cause: missing deletion_state predicate in community_hosts_with_operation (crates/buzz-db/src/store/usage.rs:399).

Fix: filter to archived_at IS NULL AND deleted_at IS NULL AND deletion_state = 'active', matching the archival/deletion predicates already used elsewhere in community.rs.

Regression test: test_community_hosts_excludes_tombstoned_communities verifies a tombstoned community is excluded while an active one is returned.

Verification:

  • cargo test -p buzz-db --lib store::usage:: — compiles, new test registered (Postgres tests are #[ignore])
  • cargo clippy -p buzz-db -- -D warnings — clean
  • cargo fmt --check -p buzz-db — clean
  • cargo check -p buzz-relay — compiles

Fixes #7558

The community_hosts_with_operation query selected every row from
communities with no deletion_state filter. After a whole-community
deletion completes, the row remains as a tombstone (deletion_state =
'tombstone') while awaiting physical retention expiry.

Both the NIP-43 maintenance sweep (usage_community_hosts) and the
push worker pass these ids to reconcile_nip43_membership_snapshots,
which calls publish_nip43_membership_list on each. The community
write fence rejects the write, producing a WARN log every ~60s
indefinitely.

Filter the enumeration to active-only communities, matching the
archival/deletion predicates already used elsewhere in community.rs.

Fixes block#7558

Signed-off-by: Olympusbuildz <Olympus.roots@outlook.com>
@olympusbuildz
olympusbuildz requested a review from a team as a code owner September 13, 2026 22:37
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 4cd82f513214aad11c2b742ce7cc7c681e8e32a0...310451ce8e9b43b9476417b1f7bf0776ffd17e06.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 310451ce8e9b43b9476417b1f7bf0776ffd17e06 to authorize a new review.
Any previous review applies only to its recorded range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] NIP-43 maintenance sweep enumerates tombstoned communities, logging "community write fenced" every ~60s forever after a completed deletion

1 participant