Skip to content

fix: Cleanup service fails execution records when reclaiming stale slots (#219) - #227

Merged
vybe merged 1 commit into
mainfrom
feature/219-cleanup-fail-executions
Mar 30, 2026
Merged

vybe merged 1 commit into
mainfrom
feature/219-cleanup-fail-executions

Conversation

@vybe

@vybe vybe commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Correlate stale Redis slot cleanup with schedule_executions DB records — when a slot is reclaimed, the corresponding execution is now marked as failed
  • Add race-condition guard (WHERE status='running') to prevent overwriting executions that completed via another path
  • Add stale_slot_executions field to CleanupReport for observability

Changes

  • src/backend/db/schedules.py — New fail_stale_slot_execution() with guarded update
  • src/backend/services/slot_service.py — cleanup_stale_slots returns Dict[str, List[str]] (agent→execution IDs)
  • src/backend/services/cleanup_service.py — Step 3 wired to fail execution records; new report field
  • src/backend/database.py — Delegation method
  • tests/test_cleanup_service.py — Updated for new stale_slot_executions field
  • docs/memory/feature-flows/cleanup-service.md — Feature flow updated

Test Plan

  • pytest tests/test_cleanup_service.py -v — 7/7 pass
  • New stale_slot_executions field present in cleanup status and trigger responses
  • Total correctly sums all fields including new one
  • Manual: trigger cleanup when stale slots exist, verify execution records are failed

Notes

Closes #219

Generated with Claude Code

…ots (#219)

When the cleanup service reclaimed stale Redis slots, the corresponding
schedule_executions DB records stayed stuck in 'running' status. Now
slot cleanup returns the reclaimed execution IDs and the cleanup service
marks them as failed with a guarded WHERE status='running' update to
prevent overwriting executions that completed via another path.

- Add fail_stale_slot_execution() with race-condition guard
- Change cleanup_stale_slots to return Dict[str, List[str]]
- Add stale_slot_executions field to CleanupReport
- Update tests and cleanup-service feature flow

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

bug: Cleanup service does not fail execution records when reclaiming stale slots

1 participant