Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When checking health of jobs on a specific queue - broken jobs for all queues are included #433

Open
2 tasks done
edwilde opened this issue Jun 7, 2024 · 2 comments
Open
2 tasks done

Comments

@edwilde
Copy link

edwilde commented Jun 7, 2024

Module version(s) affected

dev-master

Description

I have two queues running on a project, the normal queue which has many tiny jobs which can break from time to time and a large queue with important jobs which shouldn't break.

I added a task to automatically check the health of only the large queue, however I now get reports whenever any job is broken.

In the normal queue, I don't really care too much if the tiny jobs break - they'll be recreated at some point and should be fine. So I don't really need to be notified of this.

I would assume that when a queue is specified for the CheckJobHealthTask that only that queue would be checked for health, not the current behaviour which is to check the specific queue for jobs to be restarted and check all queues for broken jobs.

How to reproduce

  1. Create a job in the normal queue, with status broken
  2. Create a job in the large queue, with status new
  3. Run vendor/bin/sake dev/tasks/CheckJobHealthTask queue=3 to run a health check on the large queue (3) only

Expected

The health check runs with no exception thrown

Actual

The health check throws an exception: Exception: 1 jobs are unhealthy 😬

Possible Solution

I believe the fix should be fairly simple, adding the extra queue restriction to the filter in QueuedJobService::checkJobHealth(), so that:

$brokenJobs = QueuedJobDescriptor::get()->filter('JobStatus', QueuedJob::STATUS_BROKEN);

Becomes:

$brokenJobs = QueuedJobDescriptor::get()
	->filter(
		[
			'JobStatus' => QueuedJob::STATUS_BROKEN,
		],
	 	'JobType' => $queue,
	);

...like the others

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@michalkleiner
Copy link
Collaborator

Thanks for the report @edwilde. Keen to open a PR with the suggested change?

@edwilde
Copy link
Author

edwilde commented Jun 9, 2024

Yeah, I certainly will when I get chance @michalkleiner. I did a quick look over and it seems the unit tests are a bit lacking in that area too, so it might be longer than just a single line fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants