r41287 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41286‎ | r41287 | r41288 >
Date:15:35, 26 September 2008
Author:tstarling
Status:old
Tags:
Comment:
* Use a separate transaction for the site_stats update
* Remove obsolete runtime schema check
Modified paths:
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -1020,13 +1020,16 @@
10211021 $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
10221022 if( $row === false ) {
10231023 echo "data is missing! rebuilding...\n";
1024 -
1025 - global $IP;
1026 - require_once "$IP/maintenance/initStats.inc";
1027 - wfInitStats();
 1024+ } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
 1025+ echo "missing ss_total_pages, rebuilding...\n";
10281026 } else {
10291027 echo "ok.\n";
 1028+ return;
10301029 }
 1030+
 1031+ global $IP;
 1032+ require_once "$IP/maintenance/initStats.inc";
 1033+ wfInitStats();
10311034 }
10321035
10331036 function do_active_users_init() {
Index: trunk/phase3/includes/SiteStats.php
@@ -212,44 +212,22 @@
213213 $fname = 'SiteStatsUpdate::doUpdate';
214214 $dbw = wfGetDB( DB_MASTER );
215215
216 - # First retrieve the row just to find out which schema we're in
217 - $row = $dbw->selectRow( 'site_stats', '*', false, $fname );
218 -
219216 $updates = '';
220217
221218 $this->appendUpdate( $updates, 'ss_total_views', $this->mViews );
222219 $this->appendUpdate( $updates, 'ss_total_edits', $this->mEdits );
223220 $this->appendUpdate( $updates, 'ss_good_articles', $this->mGood );
 221+ $this->appendUpdate( $updates, 'ss_total_pages', $this->mPages );
 222+ $this->appendUpdate( $updates, 'ss_users', $this->mUsers );
224223
225 - if ( isset( $row->ss_total_pages ) ) {
226 - # Update schema if required
227 - if ( $row->ss_total_pages == -1 && !$this->mViews ) {
228 - $dbr = wfGetDB( DB_SLAVE, array( 'SpecialStatistics', 'vslow') );
229 - list( $page, $user ) = $dbr->tableNamesN( 'page', 'user' );
230 -
231 - $sql = "SELECT COUNT(*) AS total FROM $page";
232 - $res = $dbr->query( $sql, $fname );
233 - $pageRow = $dbr->fetchObject( $res );
234 - $pages = $pageRow->total + $this->mPages;
235 -
236 - $sql = "SELECT COUNT(*) AS total FROM $user";
237 - $res = $dbr->query( $sql, $fname );
238 - $userRow = $dbr->fetchObject( $res );
239 - $users = $userRow->total + $this->mUsers;
240 -
241 - if ( $updates ) {
242 - $updates .= ',';
243 - }
244 - $updates .= "ss_total_pages=$pages, ss_users=$users";
245 - } else {
246 - $this->appendUpdate( $updates, 'ss_total_pages', $this->mPages );
247 - $this->appendUpdate( $updates, 'ss_users', $this->mUsers );
248 - }
249 - }
250224 if ( $updates ) {
251225 $site_stats = $dbw->tableName( 'site_stats' );
252226 $sql = $dbw->limitResultForUpdate("UPDATE $site_stats SET $updates", 1);
 227+
 228+ # Need a separate transaction because this a global lock
 229+ $dbw->begin();
253230 $dbw->query( $sql, $fname );
 231+ $dbw->commit();
254232 }
255233 }
256234

Follow-up revisions

RevisionCommit summaryAuthorDate
r41329* Revert revert r41234 of ES-related changes. The site_stats complaint should...tstarling01:42, 28 September 2008