block/buzz · critical · anyhow::Error

Failed to ensure deployment community (required when BUZZ_RE

Error message

Failed to ensure deployment community (required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true): {e}

What it means

ensure_configured_community() idempotently inserts/returns the deployment's community row from the derived host. When that DB call fails with membership enforcement enabled, startup aborts — the subsequent allowlist backfill and owner bootstrap all depend on this community id. Without enforcement the failure is logged and boot continues.

Source

Thrown at crates/buzz-relay/src/main.rs:288

                    "Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true",
                    config.relay_url
                ));
            }
            error!(
                relay_url = %config.relay_url,
                "Could not derive a community host from relay_url; skipping membership backfill/bootstrap (non-fatal, membership not required)"
            );
            None
        } else {
            match db.ensure_configured_community(&host).await {
                Ok(record) => {
                    info!(host = %record.host, community = %record.id, "Deployment community ensured");
                    Some(record.id)
                }
                Err(e) => {
                    if config.require_relay_membership {
                        error!("Fatal: failed to ensure deployment community with membership enforcement enabled: {e}");
                        return Err(anyhow::anyhow!(
                            "Failed to ensure deployment community (required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true): {e}"
                        ));
                    }
                    error!("Failed to ensure deployment community (non-fatal, membership not required): {e}");
                    None
                }
            }
        }
    };

    // NIP-43: migrate any existing pubkey_allowlist entries to relay_members.
    // Idempotent — safe to run every startup. Must run before bootstrap_owner
    // so that existing allowlist users become relay members before the owner
    // is promoted (otherwise enabling membership locks everyone out).
    if let Some(community) = deployment_community {
        match db.backfill_from_allowlist(community).await {
            Ok(0) => {}
            Ok(n) => info!("Backfilled {n} pubkey_allowlist entries into relay_members"),

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Check Postgres health/logs at the boot timestamp — usually transient; restart the relay
  2. Verify the DB user can SELECT/INSERT on the communities table
  3. Confirm migrations ran (BUZZ_AUTO_MIGRATE or manual) so the table exists
Defensive patterns

Strategy: retry

Validate before calling

# Connectivity + writable schema check before boot.
psql "$DATABASE_URL" -c 'select 1' >/dev/null || exit 1

Try / catch

# k8s: let the kubelet retry transient boot-time DB errors
spec:
  restartPolicy: Always

Prevention

When it happens

Trigger: Transient Postgres failure or write rejection during boot; schema drift on the community table after skipped migrations; read-only database.

Common situations: Relay pod starts while the DB is restarting or failing over; DB user lacks INSERT on the community table; migrations not yet applied in a new environment.

Related errors


AI-assisted analysis of block/buzz@f956e6fe06 (2026-08-16). Data as JSON: /api/errors/76086e09ce0f1315. Report an issue: GitHub.