Make HTMLCacheUpdateJob avoid waiting on replication for no reason
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 01:36:21 +0000 (17:36 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 01:53:31 +0000 (01:53 +0000)
Change-Id: Ica381dad0bdb0555add1c7925e0e48991e7e0964

includes/jobqueue/jobs/HTMLCacheUpdateJob.php

index 7d0ada5..73fa947 100644 (file)
@@ -135,9 +135,8 @@ class HTMLCacheUpdateJob extends Job {
                $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
                // Update page_touched (skipping pages already touched since the root job).
                // Check $wgUpdateRowsPerQuery for sanity; batch jobs are sized by that already.
-               foreach ( array_chunk( $pageIds, $wgUpdateRowsPerQuery ) as $batch ) {
-                       $factory->commitAndWaitForReplication( __METHOD__, $ticket );
-
+               $batches = array_chunk( $pageIds, $wgUpdateRowsPerQuery );
+               foreach ( $batches as $batch ) {
                        $dbw->update( 'page',
                                [ 'page_touched' => $dbw->timestamp( $touchTimestamp ) ],
                                [ 'page_id' => $batch,
@@ -146,6 +145,9 @@ class HTMLCacheUpdateJob extends Job {
                                ],
                                __METHOD__
                        );
+                       if ( count( $batches ) > 1 ) {
+                               $factory->commitAndWaitForReplication( __METHOD__, $ticket );
+                       }
                }
                // Get the list of affected pages (races only mean something else did the purge)
                $titleArray = TitleArray::newFromResult( $dbw->select(