Deleting an issue answers 202, but its events stay in Discover when the delete replacement cannot be published to Kafka
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
- 18/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- clickhouse, docker, docker-compose, kafka, python
- Ambito
- backend, data-engineering, distributed-systems
Direzione di ricerca
Start in the Sentry source at src/sentry/deletions/tasks/nodestore.py, where delete_events_from_eventstore calls start_delete_groups and end_delete_groups, then follow them into src/sentry/eventstream/snuba.py and src/sentry/eventstream/kafka/backend.py, where _send swallows publish errors. Done means a failed replacement publish makes the task raise and retry, and reproducing the steps with the Kafka write ACL denied leaves no events in Discover or ClickHouse.
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 on Ubuntu 24.04, with COMPOSE_PROFILES=errors-only in .env.custom.
Steps to Reproduce
With writes to the events Kafka topic denied, DELETE /api/0/issues/{id}/ answers 202 and the issue is gone, but its events stay in Discover and in ClickHouse, and nothing retries the Snuba replacement that would remove them.
- In the self-hosted checkout, stop the stack if it is running, enable the Kafka authorizer from a compose override (no source file changes) and start everything:
docker compose stop
cat > docker-compose.override.yml <<'EOF'
services:
kafka:
environment:
KAFKA_AUTHORIZER_CLASS_NAME: "org.apache.kafka.metadata.authorizer.StandardAuthorizer"
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
EOF
docker compose up -d --wait
- Create a project and a personal token with the scopes
event:admin,event:read,org:readandproject:read. SetORG(organization slug),PID(project id),KEY(the key in the DSN) andTOKEN. Send three events that group into one issue and count them in Discover:
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":"delete-repro","level":"error"}'
done
sleep 20
GID=$(curl -s -H "$H" "$B/api/0/organizations/$ORG/issues/?project=$PID&query=delete-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&query=issue.id:$GID&project=$PID&statsPeriod=24h"
curl -s -H "$H" "$Q" | grep -o '"id":"[0-9a-f]\{32\}"' | wc -l # 3
- Deny writes to
events, delete the issue and read the taskworker log:
docker compose exec -T kafka kafka-acls --bootstrap-server localhost:29092 --add --deny-principal User:ANONYMOUS --operation Write --topic events
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE -H "$H" "$B/api/0/issues/$GID/" # 202
sleep 30
docker compose logs --since 2m taskworker | grep -E 'Could not (publish|wait)'
- Remove the ACL, then check the issue, Discover and ClickHouse:
docker compose exec -T kafka kafka-acls --bootstrap-server localhost:29092 --remove --deny-principal User:ANONYMOUS --operation Write --topic events --force
curl -s -o /dev/null -w '%{http_code}\n' -H "$H" "$B/api/0/issues/$GID/" # 404
sleep 60
curl -s -H "$H" "$Q" | grep -o '"id":"[0-9a-f]\{32\}"' | wc -l # 3
docker compose exec -T clickhouse clickhouse-client --query "SELECT count() FROM errors_local FINAL WHERE project_id = $PID AND group_id = $GID AND deleted = 0" # 3
Expected Result
A delete that answers 202 should leave no events behind in Discover or ClickHouse. If the Snuba replacement cannot be published, the task should fail and be retried until it can, instead of finishing after the payloads and the group row are already gone.
Actual Result
The DELETE answers 202 and the issue answers 404, but Discover and ClickHouse still hold all 3 events after the ACL is removed. In three runs of three deletes each, all nine issues kept all three events. Reading them again after the ACL was removed, after a wait of more than five minutes, and after restarting snuba-replacer, taskworker and web listed every event each time (27 of 27 reads). Nine deletes with the topic writable removed theirs within a minute.
The grep in step 3 prints:
taskworker-1 | 08:39:05 [ERROR] sentry.eventstream.kafka.backend: Could not publish message (error: KafkaError{code=TOPIC_AUTHORIZATION_FAILED,val=29,str="Broker: Topic authorization failed"})
taskworker-1 | 08:39:05 [ERROR] sentry.eventstream.kafka.backend: Could not wait for message delivery: KafkaError{code=TOPIC_AUTHORIZATION_FAILED,val=29,str="Broker: Topic authorization failed"}
taskworker-1 | 08:39:05 [ERROR] sentry.eventstream.kafka.backend: Could not publish message: KafkaError{code=TOPIC_AUTHORIZATION_FAILED,val=29,str="Unable to produce message: Broker: Topic authorization failed"}
After the payloads are deleted from nodestore, delete_events_from_eventstore calls start_delete_groups and end_delete_groups (nodestore.py#L276-L277). Both go through KafkaEventStream._send(..., asynchronous=False) (snuba.py#L272, snuba.py#L279-L284), which catches produce and delivery errors, logs them and returns:
The task finishes normally, so its Retry(on=(Exception,), ...) (nodestore.py#L57-L62) never applies. The Snuba replacer sets deleted = 1 only when it receives end_delete_groups (errors_replacer.py#L374-L439), so the rows stay until retention removes them. The merge, unmerge and delete-tag replacements go through the same _send (snuba.py#L286-L365). These files are unchanged on master (sentry 063a6cb, snuba df59725).
The ACL is only the simplest way to make the publish fail on demand, and I did not test other causes. A single try with the broker stopped instead did not reproduce it: the deletion task is dispatched through the same Kafka, so it waited and the delete completed once the broker was back.
The eventstream has a future-tracking producer behind tasks.producer.eventstream.rollout (default 0.0, getsentry/sentry#121671), and taskworker.skip.awaiting.futures defaults to true (getsentry/sentry#118462) (defaults.py#L4578-L4593). A fresh install uses both defaults. getsentry/sentry#129327 (open) re-raises exceptions in this task so that its retry applies, but _send catches publish errors, so none reaches the task.
A possible fix: let _send raise for these two messages and let the task re-raise it as RetryTask, as the TODO at nodestore.py#L188 asks, so that the existing retry applies.
Event ID
No response
- Lingua principale
- Shell
- Stelle
- 9.7k
- Fork
- 2k
- Merge medio
- 3g 2h
- PR unite (30g)
- 16
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/self-hosted
-
Waiting for: Product Owner
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
getsentry/self-hosted#4644 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
getsentry/self-hosted#4518 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
Waiting for: Product Owner
Difficoltà 3/5 1-2 giorni Idoneità per principianti 73/100
getsentry/self-hosted#4642 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
Waiting for: Community
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
getsentry/self-hosted#4637 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Waiting for: Product Owner
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
getsentry/self-hosted#4634 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di getsentry/self-hosted
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ajithakdev/claude-desktop-rpm#43 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
aws/aws-networking-best-practices#256 ·
I maintainer di solito rispondono entro 2 giorni
-
area:terraform source:reader type:content-error
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
stephrobert/blog-roadmap#268 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
fossi-foundation/globalfoundries-pdk-libs-gf180mcu_fd_pv#61 ·
-
openai-directory
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100