fix(cleanup): use correct TaskExecutionStatus values in retention sweeps (#862) - #864
Merged
Merged
Conversation
…eps (#862) The prune_execution_logs and prune_execution_rows methods queried for status IN ('completed', 'failed', 'terminated'), but TaskExecutionStatus uses 'success', 'failed', 'cancelled', 'skipped'. Only 'failed' rows ever matched — 'success' rows (99%+) accumulated indefinitely, causing 1.35 GB of execution_log data to build up on active instances. Fix: update both SQL predicates, the idx_executions_completed_terminal partial index in schema.py, and add a migration to drop/recreate the existing wrong index on live installs (CREATE IF NOT EXISTS alone is a no-op when the wrong index already exists). Fixes #862 Co-Authored-By: Claude <noreply@anthropic.com>
AndriiPasternak31
added a commit
that referenced
this pull request
May 17, 2026
Brings in 11 commits since the previous rebase (ba4aeae → 09c8bec), including the SITE-001 revert (#867), the cleanup retention status-value fix (#864), and the 60-min default execution timeout (#841). Conflict resolved: src/backend/db/migrations.py — kept dev's two new migration entries (default_execution_timeout_to_3600, fix_retention_index_status_values) first, then our execution_retry_count appended. All three migration functions defined; order matches each side's landing chronology. Phase A (test_cleanup_unreachable_orphan.py helper-pair) and Phase B (tests/unit/conftest.py baseline-restore) for #797 verified intact after auto-merge. Lint clean, voice_auth + cleanup tests pass under seed 12345. Refs #678
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.
Summary
prune_execution_logsandprune_execution_rowsqueried forstatus IN ('completed', 'failed', 'terminated')— values that never existed inTaskExecutionStatus. Only'failed'rows ever matched;'success'rows (99%+) silently accumulated.status IN ('success', 'failed', 'cancelled', 'skipped')(the actualTaskExecutionStatusterminal set)fix_retention_index_status_valuesto drop and recreateidx_executions_completed_terminalwith correct status values on existing installs —CREATE INDEX IF NOT EXISTSalone is a no-op when the wrong index already existsChanges
src/backend/db/schedules.py— fix status predicates inprune_execution_logsandprune_execution_rowssrc/backend/db/schema.py— fixidx_executions_completed_terminalindex definition for new installssrc/backend/db/migrations.py— add_migrate_fix_retention_index_status_valuesmigrationTest Plan
pytest tests/unit/test_execution_retention_prune.py -vsuccess,failed,cancelled,skippedrunning,queued,pending_retry'completed'/'terminated'values not prunedGET /api/monitoring/cleanup-statusshould show non-zeroexecution_logs_pruned/execution_rows_prunedon next cycleFixes #862
Generated with Claude Code