aboutsummaryrefslogtreecommitdiffstats
path: root/includes/jobqueue
diff options
context:
space:
mode:
authorGergő Tisza <tgr.huwiki@gmail.com>2023-11-29 21:21:10 -0800
committerBartosz Dziewoński <dziewonski@fastmail.fm>2023-11-30 19:37:52 +0000
commit6114f847e74e4195823e053283a34a934bc85923 (patch)
tree9fb8a287b3cf47e66a1913fb9a0899df6c17d361 /includes/jobqueue
parentcf5270aca97a24a06b3357599df76a276dc7a28b (diff)
downloadmediawikicore-6114f847e74e4195823e053283a34a934bc85923.tar.gz
mediawikicore-6114f847e74e4195823e053283a34a934bc85923.zip
JobSpecification: Inherit request ID
Make JobSpecification inherit the request ID of the queuing request just like Job does. This makes it easier to find log events for actions that are triggered by a web request but happen via jobs. Especially useful for enqueueable updates which might or might not happen via jobs depending on the load of the system at the moment. Bug: T351729 Change-Id: I965ee211b00b2b33970651368930b5c59704a827 Depends-On: Iccf0f3bf666b9a77fbbd5874fe2f56bfffc9bd4c Depends-On: I9613c8c293ac3fb4b1ac25c229bb4dc83e2f34fa
Diffstat (limited to 'includes/jobqueue')
-rw-r--r--includes/jobqueue/Job.php6
-rw-r--r--includes/jobqueue/JobSpecification.php6
2 files changed, 10 insertions, 2 deletions
diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php
index eec212c5fd5c..ec7325bb738d 100644
--- a/includes/jobqueue/Job.php
+++ b/includes/jobqueue/Job.php
@@ -21,9 +21,9 @@
* @defgroup JobQueue JobQueue
*/
+use MediaWiki\Http\Telemetry;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
-use MediaWiki\Request\WebRequest;
use MediaWiki\Title\Title;
/**
@@ -112,7 +112,9 @@ abstract class Job implements RunnableJob {
}
$this->command = $command;
- $this->params = $params + [ 'requestId' => WebRequest::getRequestId() ];
+ $this->params = $params + [
+ 'requestId' => Telemetry::getInstance()->getRequestId(),
+ ];
if ( $this->title === null ) {
// Set this field for access via getTitle().
diff --git a/includes/jobqueue/JobSpecification.php b/includes/jobqueue/JobSpecification.php
index e94176891f34..0491c280aae1 100644
--- a/includes/jobqueue/JobSpecification.php
+++ b/includes/jobqueue/JobSpecification.php
@@ -20,6 +20,7 @@
* @file
*/
+use MediaWiki\Http\Telemetry;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
@@ -63,6 +64,9 @@ class JobSpecification implements IJobSpecification {
public function __construct(
$type, array $params, array $opts = [], PageReference $page = null
) {
+ $params += [
+ 'requestId' => Telemetry::getInstance()->getRequestId(),
+ ];
$this->validateParams( $params );
$this->validateParams( $opts );
@@ -127,6 +131,8 @@ class JobSpecification implements IJobSpecification {
unset( $info['params']['rootJobTimestamp'] );
// Likewise for jobs with different delay times
unset( $info['params']['jobReleaseTimestamp'] );
+ // Identical jobs from different requests should count as duplicates
+ unset( $info['params']['requestId'] );
if ( isset( $this->opts['removeDuplicatesIgnoreParams'] ) ) {
foreach ( $this->opts['removeDuplicatesIgnoreParams'] as $field ) {
unset( $info['params'][$field] );