{"record":{"id":"511b0aad2fec5f8f","repo":"block/buzz","slug":"disable-partition-roster-trigger","errorCode":null,"errorMessage":"disable partition roster trigger","messagePattern":"disable partition roster trigger","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/buzz-db/src/store/channel_members.rs","lineNumber":3075,"sourceCode":"        db.verify_channel_roster_fence()\n            .await\n            .expect(\"migrated roster fence must verify\");\n\n        let child: String = sqlx::query_scalar(\n            \"SELECT n.nspname || '.' || c.relname \\\n             FROM pg_inherits i JOIN pg_class c ON c.oid = i.inhrelid \\\n             JOIN pg_namespace n ON n.oid = c.relnamespace \\\n             WHERE i.inhparent = 'public.events'::regclass ORDER BY i.inhrelid LIMIT 1\",\n        )\n        .fetch_one(&pool)\n        .await\n        .expect(\"load event partition\");\n        sqlx::query(sqlx::AssertSqlSafe(format!(\n            \"ALTER TABLE {child} DISABLE TRIGGER trg_events_guard_channel_roster_snapshot\"\n        )))\n        .execute(&pool)\n        .await\n        .expect(\"disable partition roster trigger\");\n        let error = db\n            .verify_channel_roster_fence()\n            .await\n            .expect_err(\"disabled partition roster fence must fail closed\");\n        assert!(\n            error.to_string().contains(&child),\n            \"verification must identify the unfenced partition: {error}\"\n        );\n\n        drop_scratch_db(&admin, pool, &scratch_name).await;\n    }\n\n    #[tokio::test]\n    #[ignore = \"requires Postgres\"]\n    async fn channel_roster_fence_verification_supports_size_one_pool() {\n        let admin = PgPool::connect(&admin_url().await)\n            .await\n            .expect(\"connect admin\");","sourceCodeStart":3057,"sourceCodeEnd":3093,"githubUrl":"https://github.com/block/buzz/blob/dad5a33865fc81a2e55b3b60746632f615ec1e3a/crates/buzz-db/src/store/channel_members.rs#L3057-L3093","documentation":"This test disables the trg_events_guard_channel_roster_snapshot trigger on a child partition so it can assert that verify_channel_roster_fence() fails closed when the guard is missing. The panic fires when the ALTER TABLE ... DISABLE TRIGGER statement itself fails, meaning the guard could not be manipulated as the test requires, so the fail-closed assertion can never run meaningfully.","triggerScenarios":"Running the #[ignore]d Postgres test that calls ALTER TABLE {child} DISABLE TRIGGER on a child partition that does not exist, is not a table (e.g. it is a view/foreign table), or where the connected role lacks ownership privileges on the partition.","commonSituations":"Schema drift between schema/schema.sql and the partition names the test hardcodes; running as a non-superuser/non-owner role that cannot ALTER TABLE; migrations renamed or dropped the trigger; connecting to the wrong database that has no partitions.","solutions":["Run against a database created from the current schema/schema.sql so the partition and trigger exist","Connect as the table owner or superuser (the admin URL role) before running the test","Verify the child partition name still matches after migrations; update the test if trigger/partition names changed","Ensure the test is only run when Postgres is up and the admin_url points at the right instance"],"exampleFix":"// before\nsqlx::query(sqlx::AssertSqlSafe(format!(\"ALTER TABLE {child} DISABLE TRIGGER trg_events_guard_channel_roster_snapshot\")))\n    .execute(&pool).await.expect(\"disable partition roster trigger\");\n// after\nsqlx::query(sqlx::AssertSqlSafe(format!(\"ALTER TABLE IF EXISTS {child} DISABLE TRIGGER IF EXISTS trg_events_guard_channel_roster_snapshot\")))\n    .execute(&pool).await.expect(\"disable partition roster trigger: is {child} a partition owned by the admin role?\");","handlingStrategy":"validation","validationCode":"let exists: bool = sqlx::query_scalar(\"SELECT EXISTS (SELECT 1 FROM pg_class WHERE relname = $1 AND relkind = 'r')\", child).fetch_one(&pool).await?;\nif !exists { panic!(\"partition {child} missing; cannot run roster fence test\"); }","typeGuard":"async fn partition_exists(pool: &PgPool, name: &str) -> bool {\n    sqlx::query_scalar::<_, bool>(\"SELECT EXISTS (SELECT 1 FROM pg_class WHERE relname = $1 AND relkind = 'r')\")\n        .bind(name).fetch_one(pool).await.unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Run #[ignore]d Postgres tests only after `just setup` provisions a current schema","Keep schema.sql, partitions, and trigger names in sync with migrations","Run these tests as the admin/superuser role"],"tags":["postgres","sql","test-infrastructure","ddl"],"backgroundTag":"alter-table-permission-denied","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"}