Repository navigation
fix(replays): Keep replay recordings in /data/replays and prune them - #4607
sentry-junior[bot] wants to merge 4 commits into
Conversation
…olicy Replay recording segments were written to the default filestore on the sentry-data volume. Sentry writes them without File rows and relies on a bucket lifecycle policy to expire them, so nothing ever deleted them. Store them in a 'replays' SeaweedFS bucket that expires objects after SENTRY_EVENT_RETENTION_DAYS, mirroring the profiles bucket setup. Refs getsentry/sentry#121278 Co-Authored-By: Dominik Buszowiecki <44422760+DominikB2014@users.noreply.github.com>
Coverage Results 📊✅ 22 passed | Total: 22 | Pass Rate: 100% | Execution Time: 9m 40s 📊 Comparison with Base Branch
✨ Test counts unchanged from base. All tests are passing successfully. ✅ Patch coverage is 100.00% (no changed executable lines found; target 50%). Coverage diff@@ Coverage Diff @@
## master #4607 +/-##
==========================================
Coverage 95.58% 95.58% —%
==========================================
Files 5 5 —
Tracked lines 339 339 —
Branches 0 0 —
==========================================
Hits 324 324 —
Misses 15 15 —
Partials 0 0 —Generated by Coverage Action |
|
@DominikB2014 I would avoid using SeaweedFS here. Can we just use |
Drop the SeaweedFS bucket in favor of the filesystem backend with a dedicated /data/replays directory. A daily sentry-cleanup cron job deletes recordings older than SENTRY_EVENT_RETENTION_DAYS. On upgrade, install points replay.storage.* at /data/replays and moves existing recordings out of /data/files so they keep playing back and expire like new ones. Co-Authored-By: Dominik Buszowiecki <44422760+DominikB2014@users.noreply.github.com>
Installs that keep the default filestore in S3 or GCS already store replay recordings in that bucket. Pointing replay.storage at /data/replays would break playback of existing recordings and start filling local disk, so leave those installs alone. Co-Authored-By: Dominik Buszowiecki <44422760+DominikB2014@users.noreply.github.com>
The move only ran on the install that appended the replay.storage config. If it failed partway, later runs saw the config and skipped the move, leaving recordings in /data/files where they could not be played back or pruned. Run the move whenever replays are configured to live in /data/replays; it skips anything already moved. Co-Authored-By: Dominik Buszowiecki <44422760+DominikB2014@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5d7bfa1. Configure here.
gggritso
left a comment
There was a problem hiding this comment.
This makes sense overall, just raised a few questions that I'm not sure about
| BASE_IMAGE: sentry-self-hosted-local | ||
| entrypoint: "/entrypoint.sh" | ||
| command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS"' | ||
| command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS" "0 0 * * * gosu sentry find /data/replays -mindepth 1 -mtime +$SENTRY_EVENT_RETENTION_DAYS -delete"' |
There was a problem hiding this comment.
Hm, I wonder if it would make sense to integrate this deletion code into sentry cleanup? I'm not sure if that would be easy or make sense here, though
There was a problem hiding this comment.
Cool, makes sense to me. Wondering if this needs a test? Maybe moving the Python code into its own file would help
|
@gggritso hey, honestly I'm not that confident about this change. the path I want to see is to move filestore into objectstore soon. |
|
@aldy505 that's fair, but even though there's a plan to move Replays to ObjectStore it's not currently scheduled, and we don't know when people will get to it (we can ask!). Is is still worth it to merge a small short-term fix? IMO yes, even if it's relying on SeaweedFS and its known problems. What's your take on this? |

Fixes an issue where replay were not getting cleaned up after retention period. This is because the nightly sentry cleanup job only deletes files it has database records for, replay recordings do not have a record. We do this by changing the default filestore location and using a nightly cron job to cleanup up data in that location when the data on the file is past the
SENTRY_EVENT_RETENTION_DAYSGenerated description
Replay recording segments are written to the default filestore (
/data/filesonsentry-data) becausereplay.storage.backendis not set. Sentry writes these blobs straight to storage, with noFilerows, sosentry cleanupnever deletes them and they pile up forever on both fresh installs and upgrades. See getsentry/sentry#121278.This keeps the
filesystembackend but pointsreplay.storage.*at a dedicated/data/replaysdirectory. A second daily cron entry insentry-cleanupdeletes anything there older thanSENTRY_EVENT_RETENTION_DAYS. The newinstall/migrate-replay-storage.shcreates the directory. On upgrades, ifAPPLY_AUTOMATIC_CONFIG_UPDATESallows it, it appends the config and moves existing recordings out of/data/files. It only moves<retention>/<project_id>/<32-hex replay_id>directories, so regular file blobs (<2hex>/<4hex>/<26hex>files) are never touched. Moved recordings keep their mtimes, so ones already past retention are removed on the next cleanup run.Open question:
APPLY_AUTOMATIC_CONFIG_UPDATES=1switch the path and move recordings without a prompt.