Infinite retry loop in RetryableJob because the canRetry/attempt not obeyed when Job/Worker segfaults
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.1k
- Forks
- 285
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 2
Description
What steps will reproduce the problem?
I am working on getting this info. It happens on a live system with a few thousand jobs per day where a few hundred segfault and get re-queued indefinitely.
The job implements \yii\queue\RetryableJobInterface and has:
public function canRetry($attempt, $error) {
return ($attempt < 3 ) && ($error instanceof TemporaryException);
}
What's expected?
Not sure if the segfault is a Queue issue, but at least the "Attempts" mechanism should work so we do not end up in an infinite race... a job should really not be retried more than twice, but I get the attempt counter (in the logs) up to 400+ (then I have to flush the queue to stop this).
What do you get instead?
Infinite re-queuing. The segfault must happen in a very awkward place in between the attempt counter being increased and canRetry call...
Additional info
Using Redis queue.
| Q | A |
|---|---|
| Yii version | 2.0.27 |
| PHP version | v7.0.33-0+deb9u5 |
| Operating system | Linux 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3 (2019-09-02) x86_64 GNU/Linux |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing RetryableJobInterface attempt handling through the Redis queue worker, focusing on what happens when a job or worker segfaults between incrementing the attempt counter and calling canRetry. Reproduce the re-queuing behavior if possible and verify that a job whose attempt limit is reached is not queued indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, redis
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100