Skip to content

Conversation

@bctiemann
Copy link
Contributor

Fixes: #17950

This alters the Job.delete() method to wrap job.cancel() in a try-except which handles the condition where the inner get_status call fails to find a non-null status for the job in Redis. This should fix a recurring intermittent test failure in test_enqueue_once_after_enqueue.

My investigation showed that whereas the job UUID key must be in Redis in order for fetch_job to work (which occurs in delete prior to the cancel call), it is occasionally the case that a call to self.connection.hget(self.key, 'status') returns a null value, leading to the exception being raised in rq/job.py#L400. This never occurs locally, and may be a side effect of concurrency within the CI environment.

The risk of this fix is low, I think, because the job.cancel is only being used in order to clear out a job from the cache during a delete operation; leaving a job in undeleted or partially-deleted state (particularly specifically in CI) is unlikely to have negative side effects.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bctiemann!

@jeremystretch jeremystretch merged commit 4f7bfc8 into develop Nov 21, 2024
6 checks passed
@jeremystretch jeremystretch deleted the 17950-fix-enqueue-job-test branch November 21, 2024 16:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix randomly failing test test_enqueue_once_after_enqueue

2 participants