From: Tim Starling Date: Wed, 11 Dec 2013 00:57:00 +0000 (+1100) Subject: Fix QueryPage transaction plan X-Git-Tag: 1.31.0-rc.0~17666^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=2be2abf30f8996bce84a4cb302c7ab2c5bded3ea;p=lhc%2Fweb%2Fwiklou.git Fix QueryPage transaction plan The COMMIT in updateSpecialPages.php was unmatched and just logged an error. We would like the stale results to still be presented to the user during the hours of query execution time, so doing a DELETE in autocommit mode before the main query starts does not seem appropriate. And holding a master transaction open for hours, with a lock on querycache, is certainly not the right way to do it. So, move the DELETE to after the completion of the main query, and wrap a transaction around the updates to querycache and querycache_info so that the user always sees a consistent populated UI. Remove the unmatched COMMIT from updateSpecialPages.php. Change-Id: I27c22b96f43a1064eb17a0c6a1c56d1f4a2dff9a --- diff --git a/includes/QueryPage.php b/includes/QueryPage.php index ff505b1509..a904c248ce 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -300,8 +300,6 @@ abstract class QueryPage extends SpecialPage { } try { - # Clear out any old cached data - $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Do query $res = $this->reallyDoQuery( $limit, false ); $num = false; @@ -327,6 +325,9 @@ abstract class QueryPage extends SpecialPage { 'qc_value' => $value ); } + $dbw->begin( __METHOD__ ); + # Clear out any old cached data + $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Save results into the querycache table on the master if ( count( $vals ) ) { $dbw->insert( 'querycache', $vals, __METHOD__ ); @@ -336,6 +337,7 @@ abstract class QueryPage extends SpecialPage { $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname ); + $dbw->commit( __METHOD__ ); } } catch ( DBError $e ) { if ( !$ignoreErrors ) { diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 3432cb2070..40c6951c65 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -112,9 +112,6 @@ class UpdateSpecialPages extends Maintenance { sleep( 10 ); } while ( !wfGetLB()->pingAll() ); $this->output( "Reconnected\n\n" ); - } else { - # Commit the results - $dbw->commit( __METHOD__ ); } # Wait for the slave to catch up wfWaitForSlaves();