Skip to content

fix(queue): delete orphaned jobs before initializeScheduling() so next_schedule actually resets#49

Merged
Vitexus merged 1 commit into
mainfrom
fix/queue-fix-schedule-reset-ordering
Jul 16, 2026
Merged

fix(queue): delete orphaned jobs before initializeScheduling() so next_schedule actually resets#49
Vitexus merged 1 commit into
mainfrom
fix/queue-fix-schedule-reset-ordering

Conversation

@Vitexus

@Vitexus Vitexus commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes queue:fix runs initializeScheduling() before deleting orphaned jobs, so next_schedule is never reset in the same pass #48
  • queue:fix (both the new Queue/FixCommand.php and the legacy QueueCommand.php fix action) called Scheduler::initializeScheduling() before deleting orphaned job rows. Since initializeScheduling() only resets a run-template's next_schedule when it finds no matching job row, it always saw the soon-to-be-deleted orphan and skipped the reset — leaving next_schedule permanently stuck at a dead slot with no way to naturally re-trigger.
  • Reordered both commands so orphan deletion happens first, then initializeScheduling() runs against the now-accurate state.

Test plan

  • php -l on both changed files
  • Local phpunit run — this repo has no phpunit.xml, so the suite isn't runnable standalone in the environment I used; the existing QueueCommandTest also requires a live MySQL instance matching .env, which wasn't available. The change is a pure statement reorder with no logic changes, verified by reading — please run CI/local suite before merge.
  • Manually verified the bug and this fix's rationale against a real MultiFlexi instance (see queue:fix runs initializeScheduling() before deleting orphaned jobs, so next_schedule is never reset in the same pass #48 for the reproduction).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved queue cleanup by removing orphaned jobs before scheduling data is initialized.
    • The queue repair command now handles missing schedule entries more reliably.
    • Existing message collection and output formats remain unchanged.

…ialization

Reordered the logic in both `Queue/FixCommand.php` and `QueueCommand.php` to delete orphaned jobs before initializing scheduling. This ensures that the scheduler correctly resets `next_schedule` for run-templates when orphans are present, addressing issue #48.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ebe94c9-1d4c-4a1b-a95f-cc08ae1cbc27

📥 Commits

Reviewing files that changed from the base of the PR and between b01034d and 6852bf3.

📒 Files selected for processing (2)
  • src/Command/Queue/FixCommand.php
  • src/Command/QueueCommand.php

📝 Walkthrough

Walkthrough

Changes

Queue cleanup ordering

Layer / File(s) Summary
Orphan cleanup before scheduling initialization
src/Command/Queue/FixCommand.php, src/Command/QueueCommand.php
The queue fix flow deletes orphaned jobs before calling Scheduler::initializeScheduling(), with comments documenting the ordering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 48 — The change directly implements the issue’s requested ordering of scheduling initialization after orphaned-job deletion.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/queue-fix-schedule-reset-ordering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Vitexus
Vitexus merged commit 1eabc58 into main Jul 16, 2026
1 of 3 checks passed
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.

queue:fix runs initializeScheduling() before deleting orphaned jobs, so next_schedule is never reset in the same pass

1 participant