Skip to content

fix: prune expired orphaned Action Scheduler logs#2891

Closed
chubes4 wants to merge 2 commits into
mainfrom
investigate/sqlite-database-bloat
Closed

fix: prune expired orphaned Action Scheduler logs#2891
chubes4 wants to merge 2 commits into
mainfrom
investigate/sqlite-database-bloat

Conversation

@chubes4

@chubes4 chubes4 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Action Scheduler custom tables have no foreign key between actions and logs. When another cleanup removes an action, Data Machine retention previously joined only to surviving terminal actions and left expired orphan logs indefinitely.

This adds a bounded orphan-log pass to the existing Action Scheduler retention task. It deletes only logs that are older than the configured global retention window, have a nonzero action_id, and no longer have a parent action. The pass shares the existing batch, iteration, and runtime caps. Dry-run counts and cleanup results now include these orphan logs.

Related upstream defect: woocommerce/action-scheduler#1347
Related retention investigation: #2792

How to test

  1. From a fresh checkout with PHP 8.2+, run php tests/retention-action-scheduler-batching-smoke.php.
  2. Confirm all 37 assertions pass, including expired orphan logs are removed while fresh orphan logs survive.
  3. Run php -l inc/Engine/AI/System/Tasks/Retention/RetentionCleanup.php and php -l tests/retention-action-scheduler-batching-smoke.php.
  4. Confirm both commands report no syntax errors.

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode, OpenAI gpt-5.6-terra
  • Used for: Investigated SQLite storage with read-only queries, identified the retention gap, drafted the bounded cleanup and functional coverage.

@chubes4

chubes4 commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

Follow-up scheduling defect filed as #2892: this recovery pass is bounded and ready to run, but the observed retention recurrence has no pending replacement after cancellation.

@chubes4

chubes4 commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

Closing without merge. A follow-up lock-respecting LEFT JOIN check found 0 orphan logs; the retention diagnosis in this PR was incorrect. The actionable recurrence failure is tracked in #2892.

@chubes4 chubes4 closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant