Make workItemCount() smarter for htmlCacheUpdate/refreshLinks
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 23 Aug 2017 17:35:04 +0000 (10:35 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 23 Aug 2017 17:35:34 +0000 (10:35 -0700)
Do not count jobs that just make subdivide as having any
"work items". This makes $wgJobBackoffThrottling less
overzealous when used to limit these type of jobs.

The main reason to limit htmlCacheUpdate would be for
CDN purge rate limiting. For refreshLinks, it would
mostly be lag, though that is already handled for
leaf jobs and JobRunner itself.

Bug: T173710
Change-Id: Ide831b555e51e3111410929a598efb6c0afc0989

includes/jobqueue/jobs/HTMLCacheUpdateJob.php
includes/jobqueue/jobs/RefreshLinksJob.php

index 2d816f9..07d68e7 100644 (file)
@@ -152,6 +152,12 @@ class HTMLCacheUpdateJob extends Job {
        }
 
        public function workItemCount() {
-               return isset( $this->params['pages'] ) ? count( $this->params['pages'] ) : 1;
+               if ( !empty( $this->params['recursive'] ) ) {
+                       return 0; // nothing actually purged
+               } elseif ( isset( $this->params['pages'] ) ) {
+                       return count( $this->params['pages'] );
+               }
+
+               return 1; // one title
        }
 }
index b4ead5d..9f3550f 100644 (file)
@@ -301,6 +301,12 @@ class RefreshLinksJob extends Job {
        }
 
        public function workItemCount() {
-               return isset( $this->params['pages'] ) ? count( $this->params['pages'] ) : 1;
+               if ( !empty( $this->params['recursive'] ) ) {
+                       return 0; // nothing actually refreshed
+               } elseif ( isset( $this->params['pages'] ) ) {
+                       return count( $this->params['pages'] );
+               }
+
+               return 1; // one title
        }
 }