Sentry On-Premise 21.7 问题排查与处理总结
时间 :2025-08-21 环境:Sentry On-Premise 21.7.0 + Docker
- 问题概述
-
现象:
- Sentry Web 页面访问报 502。
- 日志显示
uWSGI
启动后,workers 很快被 SIGINT/SIGQUIT 杀掉。 - Snuba 消费 subscriptions 报错:
OffsetOutOfRange('KafkaError{code=OFFSET_OUT_OF_RANGE,val=1,str="Broker: Offset out of range"}')
- Web 容器无法直接进入 bash(未运行)。
-
疑因:
- 数据量过大导致 Web 服务挂掉。
- Kafka 中的 subscriptions offset 超出范围导致 Snuba consumer 异常退出。
- 排查步骤与处理时间线
2.1 Day1:清理过期数据
- 通过 Postgres / Clickhouse 删除历史事件数据,降低数据量。
- 目标:减少 Web 和 Snuba 处理压力。
2.2 容器状态检查
docker ps ``docker network ls
- Web 容器仍然频繁重启,worker 和 cron 容器正常运行。
- Kafka、Postgres、Clickhouse、Redis、Memcached 容器健康。
2.3 数据库检查
docker exec -it sentry_onpremise_postgres_1 psql -U postgres ``\l # 列出数据库
\du # 列出用户
\dt # 查看表
- Postgres 默认 database 下有 Sentry 表,如:
sentry_project
sentry_team `` sentry_user ``nodestore_node
2.4 Web 日志分析
docker logs -f sentry_onpremise_web_1
- 日志显示 uWSGI 启动成功,但 workers 很快被杀掉,可能由资源或缓存异常导致。
2.5 Snuba subscriptions 错误
OffsetOutOfRange('KafkaError{code=OFFSET_OUT_OF_RANGE,val=1,str="Broker: Offset out of range"}')
- Kafka subscription consumer offset 已经过期,导致 Snuba consumer 退出。
- 处理措施
3.1 停止异常 consumer
docker stop sentry_onpremise_snuba-subscription-consumer-events_1 ``docker stop sentry_onpremise_snuba-subscription-consumer-transactions_1
3.2 重置 Kafka offset
docker exec -it sentry_onpremise_kafka_1 kafka-consumer-groups \ `` --bootstrap-server localhost:9092 \ `` --group snuba-subscription-consumer-events \ `` --reset-offsets --to-latest --execute --topic events `` docker exec -it sentry_onpremise_kafka_1 kafka-consumer-groups \ `` --bootstrap-server localhost:9092 \ `` --group snuba-subscription-consumer-transactions \ ``--reset-offsets --to-latest --execute --topic transactions
⚠️ 注意:跳过 Kafka 中过期消息,但不会删除 Clickhouse 已处理的数据。
3.3 重启 consumer
docker start sentry_onpremise_snuba-subscription-consumer-events_1 ``docker start sentry_onpremise_snuba-subscription-consumer-transactions_1
3.4 清理缓存与迁移(可选)
sentry cleanup ``sentry upgrade
- 风险:不会删除项目或用户关键数据,只清理缓存和执行迁移。
3.5 验证
- Web 页面正常访问。
- Snuba subscriptions 消费正常。
- Kafka 消费 offset 指向最新。
-
总结
-
问题主要由 Kafka offset 过期 + 数据量过大导致 Web 容器异常 引起。
-
排查顺序:
- 容器状态 → 数据库表 → Web 日志 → Snuba 日志 → Kafka offset。
-
处理方式:
- 清理历史数据 → 停止异常 consumer → 重置 Kafka offset → 重启 consumer → 验证。
-
数据安全:
- Postgres 和 Clickhouse 数据未丢失。
- 清理缓存和迁移操作不会删除关键数据。
-
建议:
- 定期清理 Kafka 和 Snuba 过期数据。
- 监控 Web 容器资源使用情况。
- 对关键 Kafka topic 和 consumer group 做备份与监控。