Make PurgeJobUtils::invalidatePages avoid waiting on replication for no reason
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 01:33:16 +0000 (17:33 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 01:53:01 +0000 (01:53 +0000)
Change-Id: I9ea4e4034ffc30a14b138279515447f990807e07

includes/jobqueue/utils/PurgeJobUtils.php

index ef364b5..1e40eb4 100644 (file)
@@ -65,7 +65,8 @@ class PurgeJobUtils {
 
                                $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
                                $ticket = $lbFactory->getEmptyTransactionTicket( $fname );
-                               foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
+                               $idBatches = array_chunk( $ids, $batchSize );
+                               foreach ( $idBatches as $idBatch ) {
                                        $dbw->update(
                                                'page',
                                                [ 'page_touched' => $now ],
@@ -75,7 +76,9 @@ class PurgeJobUtils {
                                                ],
                                                $fname
                                        );
-                                       $lbFactory->commitAndWaitForReplication( $fname, $ticket );
+                                       if ( count( $idBatches ) > 1 ) {
+                                               $lbFactory->commitAndWaitForReplication( $fname, $ticket );
+                                       }
                                }
                        }
                ) );