A resolved issue stays unresolved in Discover when Kafka is down for more than 5 minutes after the change, and nothing repairs it

Aperta
#4,608 0 commenti 0 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
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
clickhouse, docker-compose, kafka, postgresql, python

Direzione di ricerca

Start with src/sentry/issues/attributes.py at produce_snapshot_to_kafka and the post_update receiver; trace how the send result is handled when Kafka is unavailable. The report also points to src/sentry/api/helpers/group_index/update.py and src/sentry/search/events/builder/errors.py for the update path and Discover status mapping. Reproduce by stopping Kafka during a resolve, then verify that after it returns is:resolved finds the events and is:unresolved does not.

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

Descrizione

Self-Hosted Version

26.10.1

CPU Architecture

x86_64

Docker Version

29.1.3

Docker Compose Version

5.6.1

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

Fresh install of 26.10.1 (sentry commit 75be212fba6d4a1c43fc98030fc5e56edcdf176a) with ./install.sh, then docker compose up --wait. Only change: COMPOSE_PROFILES=errors-only in .env. No .env.custom, no override file.

Steps to Reproduce

Resolving an issue answers 200 and Postgres stores the new status. If Kafka stays down for more than 5 minutes after that, the new status never reaches the ClickHouse table group_attributes. Discover then lists the events of the resolved issue as unresolved, also after Kafka is back, and nothing sends the status again.

  1. Create a project and a personal token with the scopes event:admin, event:read, org:read and project:read. Set ORG (organization slug), PID (project id), KEY (the key in the DSN) and TOKEN. Send 3 events that group into one issue and count them by status:
B=http://localhost:9000
H="Authorization: Bearer $TOKEN"
for i in 1 2 3
do
  curl -s -o /dev/null -X POST "$B/api/$PID/store/?sentry_key=$KEY&sentry_version=7" -H 'Content-Type: application/json' -d '{"message":"status-repro","level":"error"}'
done
sleep 20
GID=$(curl -s -H "$H" "$B/api/0/organizations/$ORG/issues/?project=$PID&query=status-repro&statsPeriod=1h" | grep -o '"id":"[0-9]*"' | head -1 | tr -dc 0-9)
Q="$B/api/0/organizations/$ORG/events/?dataset=errors&field=id&field=issue.id&project=$PID&statsPeriod=24h"
count() {
  curl -s -G -H "$H" "$Q" --data-urlencode "query=issue.id:$GID is:$1" | grep -o '"id":"[0-9a-f]\{32\}"' | wc -l
}
count unresolved    # 3
count resolved      # 0
  1. Stop Kafka and resolve the issue. Wait 5.5 minutes, then start Kafka again:
docker compose stop kafka
curl -s -o /dev/null -w '%{http_code}\n' -X PUT -H "$H" -H 'Content-Type: application/json' -d '{"status":"resolved"}' "$B/api/0/issues/$GID/"    # 200
sleep 330
docker compose start kafka
  1. Give the services 2 minutes to reconnect, then check the issue, Discover and ClickHouse:
sleep 120
curl -s -H "$H" "$B/api/0/issues/$GID/" | grep -o '"status":"[a-z]*"' | head -n 1    # "status":"resolved"
count resolved      # 0
count unresolved    # 3
docker compose exec -T clickhouse clickhouse-client --query "SELECT group_status FROM group_attributes_local FINAL WHERE project_id = $PID AND group_id = $GID"    # 0
Expected Result

A status change that answers 200 should reach group_attributes once Kafka is back. Discover should then list the events with is:resolved and not with is:unresolved. If the delivery fails, the status should be sent again.

Actual Result

The PUT answers 200 and the issue reads resolved. After Kafka is back, Discover lists all 3 events as unresolved and none as resolved. ClickHouse still holds status 0 (unresolved). This happened in 4 of 4 runs on 3 fresh stacks, checked for up to 19 minutes.

  • A restart of web and snuba-group-attributes-consumer changes nothing.
  • Sending the same PUT again changes nothing, because an already resolved group is skipped (update.py#L475-L477).
  • Only a change of another attribute sends a new status. I set the priority to low, and then is:resolved listed the events.
  • An issue resolved 270 seconds after Kafka stopped, 60 seconds before it came back, was delivered (2 of 2 runs). With Kafka running, a resolve shows up within seconds.

Nothing logs the loss. While Kafka is down, the web log has only librdkafka connection errors, first a refused connection, later a failed name lookup (the address is the Compose network of my run). No line says that the status was dropped:

FAIL|sentry.issues.attributes#producer-1| [thrd:kafka:9092/bootstrap]: kafka:9092/bootstrap: Connect to ipv4#192.168.0.9:9092 failed: Connection refused (after 0ms in state CONNECT)
Failed to resolve 'kafka:9092': Name or service not known

The status is sent by produce_snapshot_to_kafka, and nobody reads the result of that send (attributes.py#L113-L136, details below). Master (2f1e6fe) has the same code.

getsentry/sentry#124530 shows the same symptom on sentry.io, and getsentry/sentry#127454 added snapshots to status changes that sent none. Here the snapshot is sent and its failed delivery is dropped, so neither covers this case.

A possible fix: keep the result of the produce and send the snapshot again when it fails, or send it from a task that waits for the delivery.

Where it happens in the code

Resolving makes web send a snapshot (a message with the new status) to the Kafka topic group-attributes. snuba-group-attributes-consumer writes it to group_attributes. The send is produce_snapshot_to_kafka, called from the post_update receiver inside the request (attributes.py#L246-L253):

https://github.com/getsentry/sentry/blob/75be212fba6d4a1c43fc98030fc5e56edcdf176a/src/sentry/issues/attributes.py#L113-L136

  • FutureTrackingProducer.produce returns no future (producer.py#L163-L201). The delivery callback only sets the exception on that future (consumer.py#L809-L817).
  • The producer sets no message.timeout.ms, so librdkafka drops the message after 300 seconds and nobody reads the failure.
  • The task worker can wait for these futures when ARROYO_TRACK_PRODUCER_FUTURES is set. A web request has no such step, and self-hosted does not set the variable.
  • A snapshot is sent again only when the same issue changes again.

The errors dataset maps is: and status to group_attributes.group_status (errors.py#L110-L117), so Discover, Explore and dashboards on errors keep the old status. By reading the code (I did not run it), the weekly report also picks its key error issues with group_status = UNRESOLVED (utils.py#L182-L186).

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.