Kafka consumers never recover after SESSTMOUT caused by SQLite pool stall, taskbroker stays up without consumers

未关闭
#4,569 4 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker-compose, kafka, sqlite
领域
backend, databases

调研方向

Start by tracing taskbroker's Kafka consumer lifecycle and how it handles librdkafka session timeouts and consumer group rejoining; the issue names no source files or tests, so locate those entry points in the taskbroker code first. Reproduce or inspect recovery after a SQLite pool stall, then confirm consumers rejoin or taskbroker exits when recovery fails. The issue gives no test command or specific completion test.

由索引模型根据 Issue 内容生成。

描述

Waiting for: Product Owner
Self-Hosted Version

26.9.0

CPU Architecture

x86_64

Docker Version

29.9.1

Docker Compose Version

5.6.0

Machine Specification
  • My system meets the minimum system requirements of Sentry
Installation Type

Upgrade path 26.4.2 -> 26.5.0 -> 26.7.0 -> 26.7.1 -> 26.9.0

Steps to Reproduce
Environment
  • Sentry self-hosted 26.9.0 (taskbroker 26.9.0), Docker Compose
  • Store adapter: sqlite, delivery_mode: pull
  • Host: 4 vCPU, 39 GiB RAM, Ubuntu (kernel 6.8)
  • Relevant config: kafka_session_timeout_ms: 60000, full_vacuum_on_upkeep: true, vacuum_interval_ms: 30000, full_vacuum_on_start: true
Problem

After a short stall of taskbroker's SQLite connection pool, all Kafka consumers hit a session timeout, shut down, and never rejoin their consumer groups. The taskbroker process keeps running, so the container looks healthy (the self-hosted service has no healthcheck), but no tasks are consumed anymore:

Consumer group 'taskworker' has no active members.
taskworker  taskworker  0  29758613  29759816  1203  -  -  -

Tasks pile up in Kafka until taskbroker is restarted manually. On self-hosted this eventually stops ingestion entirely: Relay can no longer fetch project configs (error fetching project state …: deadline exceeded), because the config computation tasks never run.

This happened twice within ~10 hours, with an identical sequence both times.

Logs (second occurrence, UTC)
09:55:03  ERROR get_task: taskbroker::grpc::server: Unable to retrieve pending activation: pool timed out while wa…
09:55:04  ERROR reduce:flush_reducer:flush: taskbroker::kafka::activation_writer: Unable to write …
09:55:07  ERROR reduce:flush_reducer:flush: taskbroker::kafka::activation_writer: Unable to write …
09:55:08  WARN  taskbroker: failed to run maintenance vacuum pool timed out while waiting for an open connection
09:55:14  WARN  upkeep::do_upkeep:handle_processing_deadline: sqlx::pool::acquire: acquired connection, but time to acquire exceeded slow threshold
09:55:14  WARN  vacuum_db: sqlx::pool::acquire: acquired connection, but time to acquire exceeded slow threshold
09:56:15  WARN  librdkafka: SESSTMOUT [thrd:main]: Consumer group session timed out (in join-state steady) …
09:56:17  WARN  librdkafka: SESSTMOUT … (repeated for every consumer/topic)
          INFO  handle_events: taskbroker::kafka::consumer: Received event: Revoke(…)
          INFO  handle_events:shutdown: taskbroker::kafka::consumer: Actor shutdown …
          INFO  pre_rebalance: taskbroker::kafka::consumer: Rendezvous complete

After the last Rendezvous complete, taskbroker logs nothing at all until it is restarted. The first occurrence (23:32:55 → SESSTMOUT at 23:34:15) looks exactly the same.

Observations
  • The SESSTMOUT comes almost exactly 60 s (kafka_session_timeout_ms) after the pool recovers.
  • Shorter pool stalls (time to acquire exceeded slow threshold) happen several times a day (e.g. 04:16, 04:53, 07:59, 09:21, 09:49 UTC) and usually recover on their own. vacuum_db is involved in every one of them.
  • The SQLite DB is tiny (28 KB + 4 MB WAL), so size is not the issue.
  • The host was not overloaded (CPU ~60–75% idle, low iowait and disk util per sar). Only taskbroker logged timeouts; all other Kafka consumers on the host (Snuba, Sentry consumers) were unaffected.
  • My guess is that the frequent full VACUUM, possibly combined with a short disk latency spike, holds the database long enough to block everything else, but I can't prove that.
Expected behavior

A temporary SQLite stall should not permanently disable all consumers. After a session timeout, taskbroker should either rejoin the consumer groups or exit with an error so the container gets restarted. A healthcheck that detects "no active consumers" would also make this visible.

Workaround

A cron job runs kafka-consumer-groups --describe --group taskworker every 5 minutes and restarts taskbroker if it reports "has no active members" twice in a row. This is confirmed working and limits the outage to ~10 minutes.

Related: getsentry/self-hosted#4424 (where I first reported the resulting backlog)

Expected Result

see above

Actual Result

see above

Event ID

No response

主要语言
Shell
星标
9.7k
派生
2k
平均合并
3 天 2 小时
30 天内合并 PR
16

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/self-hosted 的其他 Issue

查看 getsentry/self-hosted 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。