Deleting an issue answers 202, but its events stay in Discover when the delete replacement cannot be published to Kafka
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- clickhouse, docker, docker-compose, kafka, python
- Lĩnh vực
- backend, data-engineering, distributed-systems
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Shell
- Star
- 9.7k
- Fork
- 2k
- Merge trung bình
- 3 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/self-hosted
-
Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
getsentry/self-hosted#4644 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
getsentry/self-hosted#4518 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Waiting for: Product Owner
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 73/100
getsentry/self-hosted#4642 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Waiting for: Community
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/100
getsentry/self-hosted#4637 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Waiting for: Product Owner
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
getsentry/self-hosted#4634 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của getsentry/self-hosted
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ajithakdev/claude-desktop-rpm#43 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/aws-networking-best-practices#256 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area:terraform source:reader type:content-error
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
stephrobert/blog-roadmap#268 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fossi-foundation/globalfoundries-pdk-libs-gf180mcu_fd_pv#61 ·
-
ChatGPT directory is behind mainĐang mởopenai-directory
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100