block/buzz · error

load event partition

Error message

load event partition

What it means

Panic from `.expect("load event partition")` on a query_scalar against pg_inherits/pg_class to find a child table of public.events. Err means the query returned zero rows (no partitions found) or the catalog query itself failed, so the test cannot locate a partition whose trigger it wants to disable.

Source

Thrown at crates/buzz-db/src/store/channel_members.rs:3069

        let admin = PgPool::connect(&admin_url().await)
            .await
            .expect("connect admin");
        let (pool, scratch_name) = create_scratch_db(&admin, "roster_fence_catalog").await;
        let db = Db::from_pool(pool.clone());

        db.verify_channel_roster_fence()
            .await
            .expect("migrated roster fence must verify");

        let child: String = sqlx::query_scalar(
            "SELECT n.nspname || '.' || c.relname \
             FROM pg_inherits i JOIN pg_class c ON c.oid = i.inhrelid \
             JOIN pg_namespace n ON n.oid = c.relnamespace \
             WHERE i.inhparent = 'public.events'::regclass ORDER BY i.inhrelid LIMIT 1",
        )
        .fetch_one(&pool)
        .await
        .expect("load event partition");
        sqlx::query(sqlx::AssertSqlSafe(format!(
            "ALTER TABLE {child} DISABLE TRIGGER trg_events_guard_channel_roster_snapshot"
        )))
        .execute(&pool)
        .await
        .expect("disable partition roster trigger");
        let error = db
            .verify_channel_roster_fence()
            .await
            .expect_err("disabled partition roster fence must fail closed");
        assert!(
            error.to_string().contains(&child),
            "verification must identify the unfenced partition: {error}"
        );

        drop_scratch_db(&admin, pool, &scratch_name).await;
    }

View on GitHub (pinned to dad5a33865)

Solutions

  1. Confirm migrations created public.events as a partitioned table with children in the scratch DB
  2. Verify the table exists: SELECT 'public.events'::regclass
  3. If partitioning was renamed/removed, update the test's catalog query to the new layout
  4. Check search_path if events lives in a non-public schema

Example fix

// before
.fetch_one(&pool).await.expect("load event partition");
// after
.fetch_optional(&pool).await
    .unwrap_or_else(|e| panic!("load event partition: {e} — is events partitioned?"))
    .expect("load event partition");
Defensive patterns

Strategy: type-guard

Validate before calling

let is_partitioned: bool = sqlx::query_scalar(
    "SELECT relkind = 'p' FROM pg_class WHERE oid = 'public.events'::regclass"
).fetch_one(&pool).await?;
assert!(is_partitioned, "public.events must be partitioned");

Type guard

fn has_partitions(children: &[String]) -> bool { !children.is_empty() }

Try / catch

let child: Option<String> = sqlx::query_scalar(
    "SELECT n.nspname || '.' || c.relname FROM pg_inherits i \
     JOIN pg_class c ON c.oid = i.inhrelid \
     JOIN pg_namespace n ON n.oid = c.relnamespace \
     WHERE i.inhparent = 'public.events'::regclass ORDER BY i.inhrelid LIMIT 1"
).fetch_optional(&pool).await
 .map_err(|e| anyhow!("load event partition: {e}"))?;
let child = child.ok_or_else(|| anyhow!("public.events has no partitions"))?;

Prevention

When it happens

Trigger: public.events is not declared PARTITION BY (so pg_inherits has no rows), the scratch DB's migrations did not create partitions, or the regclass cast fails because public.events does not exist.

Common situations: Schema refactor removed/renamed partitioning on events; scratch DB created without full migrations; search_path/schema mismatch hiding public.events.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-08-30). Data as JSON: /api/errors/f0fdf099b3c19e78. Report an issue: GitHub.