feat: delete channel logs after history retention period#4586
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4586 +/- ##
==========================================
+ Coverage 89.49% 89.51% +0.01%
==========================================
Files 441 441
Lines 21249 21288 +39
==========================================
+ Hits 19017 19055 +38
- Misses 2232 2233 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Channel request logs are now cleaned up by the existing project data retention system, using the same history_retention_period setting that controls workflow run history. What this adds: - Batched deletion of expired channel_requests (by started_at) in the per-project Oban retention job, with orphaned channel_snapshot cleanup - RESTRICT FK on channel_requests.channel_id (matching the "run is king" audit integrity pattern from #4538) — deleting a channel can no longer silently destroy its request history - Explicit request cleanup in delete_channel/2 and project deletion path Migration: channel_requests.channel_id CASCADE → RESTRICT (reversible, uses NOT VALID + VALIDATE CONSTRAINT for zero-downtime).
Consolidate three copies of the CTE batch deletion pattern into a shared batch_delete_requests/1 private function. delete_channel/2 now uses the batched path (instead of unbatched Repo.delete_all) to handle high-volume channels safely. Also fixes doc terminology (ON DELETE DELETE_ALL -> on_delete: :delete_all), uses Config.activity_cleanup_chunk_size() consistently, and moves logging out of delete_unused_channel_snapshots into its caller.
1386673 to
63237ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds channel request log cleanup to the existing project data retention system, and applies the "run is king" audit integrity pattern to channel tables.
Retention cleanup:
history_retention_periodare now batch-deleted by the same Oban cron job that cleans up workflow run historydelete_workorders_historyfor DB safetyAudit integrity (FK constraint change):
channel_requests.channel_idchanged fromON DELETE CASCADEtoON DELETE RESTRICT, matching the cascade refactor in Cascade delete relationships around runs/dataclips (run is king) #4538/b4f8dceea0delete_channel/2now explicitly deletes requests before the channelhandle_delete_project) cleans up channel requests before cascadingCloses #4504
Validation steps
mix ecto.migrate— migration applies cleanlymix test test/lightning/channels_test.exs— 56 tests pass (7 new)mix test test/lightning/projects_test.exs— 116 tests pass (3 new)Additional notes for the reviewer
NOT VALID + VALIDATE CONSTRAINTfor zero-downtime deployment (same pattern as Cascade delete relationships around runs/dataclips (run is king) #4538)channel_snapshots.channel_idintentionally staysDELETE_ALL— snapshots are config records; their audit value is through requests referencing themAI Usage
Pre-submission checklist