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

Aperta
#4,569 4 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker-compose, kafka, sqlite
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Shell
Stelle
9.7k
Fork
2k
Merge medio
3g 2h
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/self-hosted

Tutte le issue di getsentry/self-hosted

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.