DCausse has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/306649

Change subject: Fix a typo in BC code that handles toId => toPageId
......................................................................

Fix a typo in BC code that handles toId => toPageId

There was a typo that could explain why CheckerJobs are checking a
huge amount pages.  $toId was certainly set to 0 causing range( $from,
$id ) to generate a huge list of chunks.

Added a bunch of new checks to make sure that currupted jobs will be
ignored.

Bug: T143862
Change-Id: I97735a28b8f64339104d7ed843cd222a1e03f945
---
M includes/Job/CheckerJob.php
1 file changed, 39 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/49/306649/1

diff --git a/includes/Job/CheckerJob.php b/includes/Job/CheckerJob.php
index b067855..2b87ce3 100644
--- a/includes/Job/CheckerJob.php
+++ b/includes/Job/CheckerJob.php
@@ -63,7 +63,7 @@
                        $params['fromPageId'] = $params['fromId'];
                        unset( $params['fromId'] );
                }
-               if ( isset( $parmas['toId'] ) ) {
+               if ( isset( $params['toId'] ) ) {
                        $params['toPageId'] = $params['toId'];
                        unset( $params['toId'] );
                }
@@ -100,6 +100,14 @@
                        return false;
                }
 
+               $chunkSize = isset( $profile['jobs_chunk_size'] ) ? 
$profile['jobs_chunk_size'] : null;
+               if ( !$chunkSize || $chunkSize < 0 ) {
+                       LoggerFactory::getInstance( 'CirrusSearch' )->warning(
+                               "Cannot run CheckerJob invalid jobs_chunk_size, 
check CirrusSearchSanityCheck config."
+                       );
+                       return false;
+               }
+
                $maxTime = isset( $profile['checker_job_max_time'] ) ? 
$profile['checker_job_max_time'] : null;
                if ( !$maxTime || $maxTime < 0 ) {
                        LoggerFactory::getInstance( 'CirrusSearch' )->warning(
@@ -108,10 +116,35 @@
                        return false;
                }
 
-               $startTime = time();
+               $from = $this->params['fromPageId'];
+               $to = $this->params['toPageId'];
+
+               if ( $from > $to ) {
+                       LoggerFactory::getInstance( 'CirrusSearch' )->warning(
+                               "Cannot run CheckerJob: from > to ( {from} > 
{to} ), job is corrupted?",
+                               [
+                                       'from' => $from,
+                                       'to' => $to,
+                               ]
+                       );
+                       return false;
+               }
+
+               if ( ( $to - $from ) > $chunkSize ) {
+                       LoggerFactory::getInstance( 'CirrusSearch' )->warning(
+                               "Cannot run CheckerJob: to - from > chunkSize( 
{from}, {to} > {chunkSize} ), job is corrupted or profile mismatch?",
+                               [
+                                       'from' => $from,
+                                       'to' => $to,
+                                       'chunkSize' => $chunkSize,
+                               ]
+                       );
+                       return false;
+               }
 
                $connections = $this->decideClusters();
                $clusterNames = implode( ', ', array_keys( $connections ) );
+
                LoggerFactory::getInstance( 'CirrusSearch' )->debug(
                        "Running CheckerJob on cluster $clusterNames {diff}s 
after insertion",
                        [
@@ -120,8 +153,7 @@
                        ]
                );
 
-               $from = $this->params['fromPageId'];
-               $to = $this->params['toPageId'];
+               $startTime = time();
 
                $pageCache = new ArrayObject();
                $checkers = [];
@@ -199,7 +231,9 @@
                LoggerFactory::getInstance( 'CirrusSearch' )->info(
                        "Sanitize CheckerJob: $cause, Requeueing CheckerJob 
with a delay of {delay}s.",
                        [
-                               'delay' => $delay
+                               'delay' => $delay,
+                               'fromPageId' => $job->params['fromPageId'],
+                               'toPageId' => $job->params['toPageId'],
                        ]
                );
                JobQueueGroup::singleton()->push( $job );

-- 
To view, visit https://gerrit.wikimedia.org/r/306649
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97735a28b8f64339104d7ed843cd222a1e03f945
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to