Skip to content

feat(deletes): Send a Sentry Log for each stage of an issue delete - #8732

Open
dezzeddi wants to merge 19 commits into
masterfrom
claude/replacer-sentry-logs-3fa66e
Open

dezzeddi wants to merge 19 commits into
masterfrom
claude/replacer-sentry-logs-3fa66e

Conversation

@dezzeddi

@dezzeddi dezzeddi commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Snuba now sends a snuba.delete.<state> Sentry Log at each stage of an issue delete.

  • Events: received, then *_written / *_failed for redis and errors, redis_skipped, and eap_deleted / eap_failed / eap_skipped for EAP.
  • Errors-path events fire only for end_delete_groups replacements.
  • enable_logs is on, but stdlib logging isn't forwarded, so only these events reach Sentry Logs.
  • No delete or retry behavior changes. Failures are logged; error handling is unchanged.

Refs EAP-964

Replace the per-message errors_replacer.process_message log with one
snuba.delete.<state> event per stage, so a delete can be followed per project
in Sentry Logs. Only end_delete_groups on the errors path and EAP deletes
are logged.

Events: received, then a written, failed and skipped event for each of
the redis, errors and eap stages (eap uses eap_deleted). Events carry
target, project_id, organization_id, group_ids_count, the first 10
group_ids, transaction_id, and reason and error where they apply. Failed
events are sent at error level.

Replacement insert executors now return the written row count and
whether the backup executor ran, for errors_written.

Refs EAP-964
@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

EAP-964

On multi-node clusters the replacer uses the sharded executor, so the
patched QueryNodeExecutor never ran and the test did not raise.

Refs EAP-964
Send each event with one sentry_sdk.logger call where the state happens,
using only values already in scope. Remove the delete_log helper module, the
insert executor changes, the extra skip and produce-failure events, and the
per-event tests. Keep one test for the received event.

Refs EAP-964
Log directly inside the type checks instead of building a conditional
delete_attrs dict first. Remove the last delete log test.

Refs EAP-964
Add the delete_sentry_logs_enabled sentry-option (default false). A
before_send_log in setup_sentry drops snuba.delete.* logs unless it is on,
so they can be turned on per region without a deploy.

Refs EAP-964
_execute_single_delete swallows non-retryable ClickHouse errors, so
eap_deleted fired after eap_failed. It now returns False when it swallows an
error, and eap_deleted is sent only if every table's delete succeeded.

Refs EAP-964
Leave ErrorsReplacer.pre_replacement as on master. flush_batch sends the
redis and errors delete logs through one small _log_delete function, based
on what pre_replacement returned or raised.

Refs EAP-964
After each table's delete, send eap_deleted or eap_failed with storage,
table, organization_ids and project_ids. A swallowed error and a raised one
both count as failed. Logs now cover every lw_deletions storage.

Refs EAP-964
Put strategy.py back to master and only add the log calls: eap_deleted
after a delete query succeeds, eap_failed in the existing except, with
storage, table and partition_week.

Refs EAP-964
Put the replacer, errors replacer and delete endpoint back to master and
add only log calls in existing branches. Drop the events that needed new
try/except blocks (redis_failed, errors_failed, and eap_failed on the delete
endpoint). Events sent from shared replacer branches carry message_type.

Refs EAP-964
Add redis_failed and the redis store name; errors_written and
errors_failed per ClickHouse connection with host and written_rows; RPC
eap_failed and eap_queued; org and project ids on the consumer's per-table
events; eap_skipped for already-deleted partitions; eap_delayed when the
consumer applies backpressure.

Refs EAP-964
…cer-sentry-logs-3fa66e

# Conflicts:
#	snuba/lw_deletions/off_peak.py
Write the attributes straight into the errors_failed and errors_written
log calls instead of a shared attributes variable.
Drop the errors_skipped event and write the redis_skipped attributes
inline.
Build the eap log attributes from conditions where they are logged, so
FormatQuery no longer keeps them in an instance variable.
@dezzeddi
dezzeddi marked this pull request as ready for review November 23, 2026 19:09
@dezzeddi
dezzeddi requested review from a team as code owners November 23, 2026 19:09

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b6b2140. Configure here.

Comment thread snuba/replacer.py Resolved
Comment thread snuba/lw_deletions/strategy.py Resolved
Comment thread snuba/web/bulk_delete_query.py Resolved
Move eap_queued into produce_delete_query's try block and send eap_failed
when the produce raises, so a dropped produce isn't logged as queued.
Merges, unmerges, tombstones and other errors replacements no longer send
snuba.delete.* logs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant