From: Brion Vibber Date: Mon, 14 Sep 2009 22:32:30 +0000 (+0000) Subject: Cleanup live hack from wmf-deployment r53208 a bit: DB selection using load balancer. X-Git-Tag: 1.31.0-rc.0~39726 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=506a19b7af78bcf8ad437743ee1d7b6e39d0a272;p=lhc%2Fweb%2Fwiklou.git 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 :) --- diff --git a/maintenance/backup.inc b/maintenance/backup.inc index e546df4f86..30bd0d88f8 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -232,21 +232,13 @@ class BackupDumper { $this->startTime = wfTime(); } + /** + * @fixme the --server parameter is currently not respected, as it doesn't seem + * terribly easy to ask the load balancer for a particular connection by name. + */ function backupDb() { - global $wgDBadminuser, $wgDBadminpassword; - global $wgDBuser, $wgDBpassword; - global $wgDBname, $wgDebugDumpSql, $wgDBtype; - $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack - - if ( !$wgDBadminuser ) { - $wgDBadminuser = $wgDBuser; - } - if ( !$wgDBadminpassword ) { - $wgDBadminpassword = $wgDBpassword; - } - - $class = 'Database' . ucfirst($wgDBtype); - $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags ); + $this->lb = wfGetLBFactory()->newMainLB(); + $db = $this->lb->getConnection( DB_SLAVE, 'backup' ); // Discourage the server from disconnecting us if it takes a long time // to read out the big ol' batch query. @@ -254,6 +246,12 @@ class BackupDumper { return $db; } + + function __destruct() { + if( isset( $this->lb ) ) { + $this->lb->closeAll(); + } + } function backupServer() { global $wgDBserver;