{"record":{"id":"d0ffa0e1030a2b34","repo":"block/buzz","slug":"insert-kind-30618-e","errorCode":null,"errorMessage":"insert kind:30618: {e}","messagePattern":"insert kind:30618: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/buzz-relay/src/handlers/side_effects.rs","lineNumber":2942,"sourceCode":"    repo_id: &str,\n) -> anyhow::Result<()> {\n    use crate::api::git::manifest_event::{build_ref_state_event, RefStateInputs};\n    use std::collections::BTreeMap;\n\n    let empty_refs: BTreeMap<String, String> = BTreeMap::new();\n    let inputs = RefStateInputs {\n        repo_id,\n        head: DEFAULT_HEAD,\n        refs: &empty_refs,\n        actor_pubkey_hex: owner_hex,\n    };\n    let event = build_ref_state_event(&inputs, &state.relay_keypair)\n        .map_err(|e| anyhow::anyhow!(\"build_ref_state_event: {e}\"))?;\n    let (stored, was_inserted) = state\n        .db\n        .insert_event_with_serving_write_guard(lease, &event, None)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"insert kind:30618: {e}\"))?;\n    if was_inserted {\n        // Routed through the guarded send path for uniformity; the access gate\n        // no-ops for this globally-scoped (channel_id = None) ref-state event.\n        crate::handlers::event::fan_out_event_to_local_subscribers(\n            state,\n            tenant.community(),\n            &stored,\n        )\n        .await;\n    }\n    Ok(())\n}\n\n/// Reconcile every community's event-backed NIP-43 membership view.\n///\n/// `relay_members` is canonical. A snapshot is rebuilt only when it is absent\n/// or its member/role set differs from the canonical rows. This makes the sweep\n/// safe to run at startup and periodically without producing an event stream","sourceCodeStart":2924,"sourceCodeEnd":2960,"githubUrl":"https://github.com/block/buzz/blob/dad5a33865fc81a2e55b3b60746632f615ec1e3a/crates/buzz-relay/src/handlers/side_effects.rs#L2924-L2960","documentation":"After building the initial kind:30618 ref-state event, emit_initial_ref_state persists it with insert_event_with_serving_write_guard under the community serving lease. This error wraps DB insert failure — the initial ref snapshot could not be stored, so repo announcement fails (distinct from the non-fatal message when was_inserted is false).","triggerScenarios":"DB unreachable or erroring during handle_git_repo_announcement_inner; the serving lease was invalidated (community deletion closed the fence) so the guarded insert refuses; schema/constraint violation on the events table.","commonSituations":"Postgres outage or connection-pool exhaustion during an announcement burst; deletion racing with the insert; duplicate insert races that surface as constraint errors instead of was_inserted=false.","solutions":["Read wrapped {e}: if it's a DB connection error, check Postgres health and retry the announcement.","If the lease was invalidated, treat like the other fence errors — retry after the deletion settles.","Check whether a kind:30618 for this repo/lease already exists (was_inserted=false path) — the state may already be correct.","Verify migrations are current (`just setup` runs migrations) if the error mentions missing columns/tables."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"sqlx::query(\"SELECT 1\").fetch_one(&state.db).await?; // DB reachable\nanyhow::ensure!(lease_valid, \"serving lease must be held before insert\");","typeGuard":null,"tryCatchPattern":"match state.db.insert_event_with_serving_write_guard(lease, &event, None).await {\n    Err(e) if is_transient_db(&e) => {\n        backoff_retry(|| reannounce(repo_id), 3).await\n    }\n    Err(e) => Err(anyhow!(\"insert kind:30618: {e:#}\")),\n    Ok((stored, _)) => Ok(stored),\n}","preventionTips":["Keep Postgres connection pools sized for announcement bursts.","Ensure migrations are applied before relay startup.","Treat duplicate-insert errors by checking existing kind:30618 state first."],"tags":["database","postgres","git","relay"],"backgroundTag":"database-insert-failed","analyzedSha":"dad5a33865fc81a2e55b3b60746632f615ec1e3a","analyzedAt":"2026-08-30T13:49:18.474Z","contentChangedAt":"2026-08-30T13:49:18.474Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}