{"record":{"id":"fa32a0e011d90ed9","repo":"block/buzz","slug":"pubsub-init-failed-e-fa32a0","errorCode":null,"errorMessage":"PubSub init failed: {e}","messagePattern":"PubSub init failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/buzz-relay/src/main.rs","lineNumber":379,"sourceCode":"            .map_err(|e| anyhow::anyhow!(\"Audit DB connection failed: {e}\"))?;\n        info!(\"Audit service ready\");\n        Some(AuditService::new(audit_pool))\n    } else {\n        info!(\"Audit logging disabled by BUZZ_AUDIT_ENABLED\");\n        None\n    };\n\n    let redis_pool = {\n        let mut cfg = deadpool_redis::Config::from_url(&config.redis_url);\n        cfg.pool = Some(deadpool_redis::PoolConfig::new(config.redis_pool_size));\n        cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1))\n            .map_err(|e| anyhow::anyhow!(\"Redis pool creation failed: {e}\"))?\n    };\n    let redis_health_pool = redis_pool.clone(); // cheap Arc clone — shared with readiness handler\n    let pubsub = Arc::new(\n        PubSubManager::new(&config.redis_url, redis_pool)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"PubSub init failed: {e}\"))?,\n    );\n    info!(\"Redis pub/sub connected\");\n\n    // Spawn Redis pub/sub subscriber for multi-node fan-out.\n    // Events published by other relay instances are received here and\n    // fanned out to local WebSocket subscribers.\n    let pubsub_for_sub = Arc::clone(&pubsub);\n    tokio::spawn(async move { pubsub_for_sub.run_subscriber().await });\n\n    // Spawn Redis pub/sub subscriber for cross-pod cache-key invalidation.\n    // Membership / visibility changes on other pods are received here and the\n    // matching local moka caches are dropped (via the consumer loop below).\n    let pubsub_for_cache = Arc::clone(&pubsub);\n    tokio::spawn(async move { pubsub_for_cache.run_cache_invalidation_subscriber().await });\n\n    // Spawn Redis pub/sub subscriber for cross-pod connection-control commands.\n    // Bans recorded on other pods are received here and applied to any local\n    // sockets (via the consumer loop below), enforcing live disconnect fan-out.","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/block/buzz/blob/f956e6fe06a76e50cbd8fba1a162482e752e7f1a/crates/buzz-relay/src/main.rs#L361-L397","documentation":"PubSubManager::new() establishes the Redis connection used for pub/sub fan-out (multi-node event distribution, presence, typing indicators). Unlike pool creation, this actually dials Redis, so an unreachable server, auth failure, or ACL restriction aborts startup with the underlying error.","triggerScenarios":"Redis not running or wrong host/port; AUTH required but no credentials in REDIS_URL; the Redis user's ACL lacks SUBSCRIBE/PUBLISH; TLS mismatch against managed Redis.","commonSituations":"Redis container starting later than the relay; ElastiCache/managed Redis requiring rediss:// or AUTH; VPC/security groups blocking 6379; connection limits exhausted.","solutions":["Verify reachability and auth: `redis-cli -u \"$REDIS_URL\" ping`","Start Redis / fix host+port / add credentials to REDIS_URL","For managed Redis use rediss:// and confirm the ACL allows pub/sub commands"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Pub/sub actually dials Redis — prove reachability and auth first.\nredis-cli -u \"$REDIS_URL\" ping || { echo 'redis unreachable or auth failed'; exit 1; }","typeGuard":null,"tryCatchPattern":"relay:\n  restart: on-failure:5\nredis:\n  healthcheck:\n    test: [\"CMD\", \"redis-cli\", \"ping\"]","preventionTips":["Order startup: Redis healthy before the relay","Confirm the Redis ACL/user permits SUBSCRIBE and PUBLISH, not just GET/SET","Use rediss:// against TLS-required managed Redis"],"tags":["redis","pubsub","connection","startup"],"backgroundTag":"redis-connection-failed","analyzedSha":"f956e6fe06a76e50cbd8fba1a162482e752e7f1a","analyzedAt":"2026-08-16T22:11:40.750Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}