Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Command/Queue/FixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$scheduler = new Scheduler();
$scheduler->cleanupOrphanedJobs();
$scheduler->purgeBrokenQueueRecords();
$scheduler->initializeScheduling();

// Delete orphaned jobs (job rows with no matching schedule entry) before
// initializeScheduling() runs, so it correctly sees their runtemplates as
// missing a job and resets next_schedule instead of finding the
// soon-to-be-deleted orphan and leaving next_schedule stuck.
$jobModel = new \MultiFlexi\Job();
$orphanedJobs = $jobModel->listingQuery()
->where('job.begin IS NULL')
Expand All @@ -62,6 +65,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
}

$scheduler->initializeScheduling();

$messages = [];

foreach ($scheduler->getStatusMessages() as $message) {
Expand Down
9 changes: 6 additions & 3 deletions src/Command/QueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$scheduler = new Scheduler();
$scheduler->cleanupOrphanedJobs();
$scheduler->purgeBrokenQueueRecords();
$scheduler->initializeScheduling();

// Delete orphaned jobs: jobs that haven't started, haven't finished,
// and have no corresponding entry in the schedule table.
// Delete orphaned jobs (job rows with no matching schedule entry) before
// initializeScheduling() runs, so it correctly sees their runtemplates as
// missing a job and resets next_schedule instead of finding the
// soon-to-be-deleted orphan and leaving next_schedule stuck.
// These jobs are stuck and will never execute.
$jobModel = new \MultiFlexi\Job();
$orphanedJobs = $jobModel->listingQuery()
Expand All @@ -482,6 +483,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
}

$scheduler->initializeScheduling();

$messages = [];

foreach ($scheduler->getStatusMessages() as $message) {
Expand Down
Loading