Page MenuHomePhabricator

Support one-time job scheduling
Closed, ResolvedPublic

Description

I'd like to enqueue a job which will not be run until a specified time in the future.

Currently, my only option seems to be something really evil involving backoffs and a Job::run() method which intentionally fails until the desired time.

Ideally, we could deprecate the mw-runJobs-backoffs.json system in favor of a not_until column in the job table.

My use case is almost too hypothetical to mention: a workflow engine which can do things like abandon AfD cases after a set number of days.


Version: unspecified
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=61148

Details

Reference
bz60217

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:05 AM
bzimport set Reference to bz60217.
bzimport added a subscriber: Unknown Object (MLST).

*** Bug 61148 has been marked as a duplicate of this bug. ***

It'd be nice to be able to register a job to execute after a certain amount of
time. My particular use case revolves around Elasticsearch's refresh interval:
once you push something to it you have to wait a second before you can query
that new data. Since we use Elasticsearch to count links we'd like to be sure
that updates that we just performed have hit the index.

Merging the bug I just filed with this one as they are pretty much the same. I will, though, bump the priority because my use case is not hypothetical.

Looks like JobQueueRedis supports a "jobReleaseTimestamp" timestamp. I'll play with it.

OK, so three things:

  1. You have to turn it on even if you are using the redis job queue: $wgJobTypeConf['default'] = array( 'class' => 'JobQueueRedis', 'order' => 'fifo', 'redisServer' => 'localhost', 'checkDelay' => true, 'redisConfig' => array( 'password' => $wgRedisPassword, ), );
  1. If you try to use 'jobReleaseTimestamp' when it isn't on you'll get an error. So if you want to optionally use it, you need something like this:

$jobQueueGroup = JobQueueGroup::singleton();
$jobQueue = $jobQueueGroup->get( 'cirrusSearchLinksUpdateSecondary' );
if ( $jobQueue->delayedJobsEnabled() ) {

		$params[ 'jobReleaseTimestamp' ] = time() + 60;

}

  1. WMF doesn't have this on right now. I wonder why.
Aklapper lowered the priority of this task from Medium to Lowest.Apr 9 2015, 12:35 PM
aaron claimed this task.
aaron subscribed.

Long since available