self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Debug files being deleted if SENTRY_EVENT_RETENTION_DAYS is lower than 30 days

Open scharli opened this issue 1 year ago • 5 comments

Environment

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

Steps to Reproduce

  1. Set SENTRY_EVENT_RETENTION_DAYS lower than 30 days (example is 1 day)
  2. Upload a debug file in an project
  3. Send events that need this debug file
  4. Wait 2 days
  5. Send events that need this debug file, date_accessed will not be updated
  6. Execute a cleanup setting 1 day
  7. Debug file will be removed

Expected Result

Debug file shouldn't be removed because was used the same day as the cleanup was executed

Actual Result

Debug file is removed because AVAILABLE_FOR_RENEWAL_DAYS is set to 30 days so date_accessed will not be updated inside maybe_renew_debug_files method because this field is updated if 30 days has passed

AVAILABLE_FOR_RENEWAL_DAYS should set to 1 day (or maybe less than 24 hours) so any value of SENTRY_EVENT_RETENTION_DAYS greater than 1 (or 0 if is managed in hours) will work the expected way

Product Area

Processing

Link

No response

DSN

No response

Version

24.8.0

scharli avatar Aug 22 '24 14:08 scharli

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Aug 22 '24 14:08 getsantry[bot]

For now the workaround is just skip this model particulary and apply the rest, so the command in docker-compose look like this:

command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS -m ApiGrant -m ApiToken -m ArtifactBundle -m EventAttachment -m ExportedData -m FileBlob -m Group -m GroupEmailThread -m GroupRuleStatus -m LostPasswordHash -m MonitorCheckIn -m NotificationMessage -m OrganizationMember -m ReplayRecordingSegment -m RuleFireHistory -m UserReport"'

scharli avatar Sep 13 '24 14:09 scharli

@hubertdeng123 I don't know if this is something that most users will encounter as I don't use debug files myself. Should we just put this on the docs? But if there's a model name changes, we'd need to update the docs more often than we'd need to?

ref: https://github.com/getsentry/sentry/blob/a49edf8ae43666338ccb0d9992fd4e7148c8fb13/src/sentry/runner/commands/cleanup.py#L104-L143

aldy505 avatar Oct 02 '24 05:10 aldy505

@aldy505 Maybe one posible solution is to add a --excludemodel option that is easier to handle to write down all possible models just to exclude one. Good be great and easy to mantain (will be in the same file) in the help a of all models executed In my research to find a workaround to the problem sentry cleanup --days 90 --model xxx to be able to list all models within the >> Skipping MODELNAME

Thanks for your time

scharli avatar Nov 02 '24 17:11 scharli

Hey @scharli sorry for the very long wait. I don't have the capacity (or the courage) to do this, but if you are willing to contribute to the sentry repo to fix this thing, and link your PR here, I'll help bumping it to the employees so that they can merge it.

aldy505 avatar Jan 22 '25 11:01 aldy505