yiisoft / yiisoft/yii2-queue

Ability to take off reserve from job

Open
#228 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:enhancement
Dominant language
PHP
Stars
1.1k
Forks
285
Avg merge
5d 3h
Merged PRs (30d)
2

Description

Can we add functionality to take off reserve from job to make it immediately available for workers?
After job being reserved we need to wait TTR before job expired and moved back to waiting list to start new attempt.
Also i found in documentation dirty workaround for this problem:

Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
    if ($event->error instanceof TemporaryUnprocessableJobException) {
        $queue = $event->sender;
        $queue->delay(7200)->push($event->job);
    }
});

It works great but we are pushing New job with new ID attached to it so old one is lost and it makes mess in logs etc

Maybe we can add some release() method to handle it:

Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
    if ($event->error instanceof TemporaryUnprocessableJobException) {
        $queue = $event->sender;
        $queue->delay(7200)->release($event->job);
    }
});

For an example in DB driver it's simply must reset reserved_at to null and update pushed_at to current time()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the queue and DB-driver implementations around job reservation and the Queue::EVENT_AFTER_ERROR flow. Compare how reserved jobs are represented, including reserved_at and pushed_at, and determine which supported drivers need release behavior. Done means the issue's release() use case is supported without creating a new job ID and is covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.