Cleanup old data
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
No files, tests, or entry points are named. Review the existing Sentry cleanup job and retention behavior for sentry_auditlogentry, sentry_file, sentry_fileblob, and sentry_userip, then determine which tables need configurable retention and how the duplicate-index upgrade cases relate. Done requires an agreed table scope, retention policy, and upgrade-safe behavior.
Written by the indexing model from the issue text.
Description
As part of the self hosted upgrade to 26.9.0 I have encountered quite a few of unique constraint errors on re-index.
For now I was able to fix those errors manually, but in doing so I noticed, that there were a few tables in the postgres instance, that had data present which was 2+ years old - which I don't think is necessary to keep.
Here are some of my errors I encountered while doing the upgrade:
ERROR: could not create unique index "sentry_release_organization_id_version_65da5843_uniq"
DETAIL: Key (organization_id, version)=(1, Zi8Qa7e9j_dtyKR4GOrq3) is duplicated.
postgres=# SELECT id, version, date_added, user_agent FROM sentry_release WHERE version='Zi8Qa7e9j_dtyKR4GOrq3';
id | version | date_added | user_agent
------+-----------------------+-------------------------------+-----------------------------------------
4819 | Zi8Qa7e9j_dtyKR4GOrq3 | 2024-08-30 07:44:11.197817+00 | sentry-cli/1.77.3 webpack-plugin/1.21.0
4818 | Zi8Qa7e9j_dtyKR4GOrq3 | 2024-08-30 07:44:10.840451+00 | sentry-cli/1.77.3 webpack-plugin/1.21.0
and
ERROR: could not create unique index "unique_org_string"
DETAIL: Key (string, organization_id)=(d4d4d88fc37dcd5e17ea30a4074b9c98065280b4, 1) is duplicated.
postgres=# SELECT *
FROM sentry_stringindexer
WHERE string IN (
SELECT string
FROM sentry_stringindexer
GROUP BY string
HAVING COUNT(*) > 1
)
ORDER BY string;
id | string | organization_id | date_added | last_seen | retention_days
-----+------------------------------------------+-----------------+-------------------------------+-------------------------------+----------------
400 | d4d4d88fc37dcd5e17ea30a4074b9c98065280b4 | 1 | 2025-06-18 12:06:59.306133+00 | 2025-06-18 12:06:59.30614+00 | 90
401 | d4d4d88fc37dcd5e17ea30a4074b9c98065280b4 | 1 | 2025-06-18 12:07:10.29119+00 | 2025-06-18 12:07:10.291192+00 | 90
(2 rows)
after doing this cleanup I also checked all tables present in postgres and can now provide this list, which also contains +2 year old data (no idea if this is needed for something)
- sentry_auditlogentry (5.000 rows)
- sentry_file (10.000 rows)
- sentry_fileblob (10.000 rows)
- sentry_userip (2.000 rows)
All of these have data still present from 3+ years ago
There were a few other talbes with old data as well, but they just had a few hundred rows if even.
Maybe this should be part of the sentry cleanup job to remove data from certain tables after they a configurable amount of time has passed.
I will re-check this in like 6 months after my instance re-fills with events and data and - if needed - will create a new issue then with the new info related to the other tables.
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 21h 28m
- Merged PRs (30d)
- 599
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry
-
Bug Cocoa Replays
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Bug Product Area: Ingestion and Filtering Spans
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Bug Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Product Area: Settings - Auth Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Bug Good First Issue Product Area: Settings - Integrations
Difficulty 1/5 Under an hour Newbie friendliness 90/100
All issues in getsentry/sentry
Similar issues
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100