r56347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56346‎ | r56347 | r56348 >
Date:22:32, 14 September 2009
Author:brion
Status:ok
Tags:
Comment:
Cleanup live hack from wmf-deployment r53208 a bit: DB selection using load balancer.

Should fix a couple regressions or possible regressions:
* Hack was pulling the main LB's DB_SLAVE connection although we were deliberately opening a new connection. Could have caused problems when we were fetching other things from the local database in the middle of an export.
* We no longer lose the connection timeout override.

However we still have a regression:
* --server option is ignored (but we're now pulling from the 'backup' group, so we at least have some kind of consistency :)
Modified paths:
  • /trunk/phase3/maintenance/backup.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/backup.inc
@@ -232,28 +232,26 @@
233233 $this->startTime = wfTime();
234234 }
235235
 236+ /**
 237+ * @fixme the --server parameter is currently not respected, as it doesn't seem
 238+ * terribly easy to ask the load balancer for a particular connection by name.
 239+ */
236240 function backupDb() {
237 - global $wgDBadminuser, $wgDBadminpassword;
238 - global $wgDBuser, $wgDBpassword;
239 - global $wgDBname, $wgDebugDumpSql, $wgDBtype;
240 - $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack
 241+ $this->lb = wfGetLBFactory()->newMainLB();
 242+ $db = $this->lb->getConnection( DB_SLAVE, 'backup' );
241243
242 - if ( !$wgDBadminuser ) {
243 - $wgDBadminuser = $wgDBuser;
244 - }
245 - if ( !$wgDBadminpassword ) {
246 - $wgDBadminpassword = $wgDBpassword;
247 - }
248 -
249 - $class = 'Database' . ucfirst($wgDBtype);
250 - $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags );
251 -
252244 // Discourage the server from disconnecting us if it takes a long time
253245 // to read out the big ol' batch query.
254246 $db->setTimeout( 3600 * 24 );
255247
256248 return $db;
257249 }
 250+
 251+ function __destruct() {
 252+ if( isset( $this->lb ) ) {
 253+ $this->lb->closeAll();
 254+ }
 255+ }
258256
259257 function backupServer() {
260258 global $wgDBserver;

Follow-up revisions

RevisionCommit summaryAuthorDate
r56374Merge post-branch trunk updates replacing old live hacks:...brion17:25, 15 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53208Apply live hacks, local merges, and removal of SVN externals -- all copied fr...brion23:50, 13 July 2009

Status & tagging log