Skip to content

Crash-report limit count seq-scans sentry_eventattachment and saturates Postgres #131176

Open

Description

@bhataprameya

Environment

self-hosted (https://develop.sentry.dev/self-hosted/)

Steps to Reproduce

  1. Self-hosted Sentry 26.10.1, Postgres 16.
  2. Set a finite "store crash reports" limit (for example 20 per issue).
  3. Have a busy issue with a huge number of normal attachments and only a few crash dumps.
  4. Keep sending crash dumps for that issue.

Expected Result

Sentry asks "does this issue already have enough crash dumps?" only until the limit is hit, then remembers the answer. Each check should be a tiny index lookup.

That is what #15798 describes. The check is get_stored_crashreports in src/sentry/event_manager.py.

Actual Result

Sentry forgets the answer after 24 hours and asks again on every crash dump. Postgres answers by reading the whole attachments table, because there is no index on (group_id, type).

On a 4 vCPU database this filled the CPU (about 18% to 98%). One check took 2.6 seconds. Restarting Postgres did not help. The plan flipped back and forth earlier in the week, so this was a bad query plan, not a traffic spike.

Workaround that fixed it:

CREATE INDEX CONCURRENTLY sentry_eventattachment_group_id_type
  ON sentry_eventattachment (group_id, type);

The same check then took 0.04 ms, and CPU fell immediately. The check still runs every time; the index only makes it cheap.

Product Area

Ingestion and Filtering

Version

26.10.1

Suggested fix

  • Ship that (group_id, type) index in a migration.
  • When an issue is already at the cap, write the 24 hour cache again. Today it is written only the first time the cap is crossed, so it never comes back after it expires.

Activity

  1. getsantry commented on Nov 14, 2026

    @getsantry
    Contributor

    Assigning to @getsentry/support for routing ⏲️

  2. linear-code commented on Nov 14, 2026

    @linear-code
  3. moved this to Waiting for: Support in GitHub Issues with 👀 3on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions