Fix old regression in HTMLCacheUpdate de-duplication
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 25 Aug 2017 22:47:01 +0000 (15:47 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 25 Aug 2017 22:49:49 +0000 (15:49 -0700)
* The condition timestamp should be the root job timestamp,
  as the comments imply, though that was not the case. Only
  the SET timestamp should be the current timestamp. As it
  was, jobs effectively did not "see" each other since each
  one would be expecting newer than the ones that ran prior.
  The page_touched condition for the UPDATE query was mostly
  useless, since it was always the current timestamp.
* This problem was a regression from f598ca81e3f40166.

Change-Id: I1398366e87c959be1c98e4db959c41309b0ac1b8

includes/jobqueue/jobs/HTMLCacheUpdateJob.php

index 9d0f87c..4c16d7f 100644 (file)
@@ -113,6 +113,10 @@ class HTMLCacheUpdateJob extends Job {
                // before the link jobs, so using the current timestamp instead of the root timestamp is
                // not expected to invalidate these cache entries too often.
                $touchTimestamp = wfTimestampNow();
+               // If page_touched is higher than this, then something else already bumped it after enqueue
+               $condTimestamp = isset( $this->params['rootJobTimestamp'] )
+                       ? $this->params['rootJobTimestamp']
+                       : $touchTimestamp;
 
                $dbw = wfGetDB( DB_MASTER );
                $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
@@ -126,7 +130,7 @@ class HTMLCacheUpdateJob extends Job {
                                [ 'page_touched' => $dbw->timestamp( $touchTimestamp ) ],
                                [ 'page_id' => $batch,
                                        // don't invalidated pages that were already invalidated
-                                       "page_touched < " . $dbw->addQuotes( $dbw->timestamp( $touchTimestamp ) )
+                                       "page_touched < " . $dbw->addQuotes( $dbw->timestamp( $condTimestamp ) )
                                ],
                                __METHOD__
                        );