http://www.mediawiki.org/wiki/Special:Code/MediaWiki/56347
Revision: 56347
Author: brion
Date: 2009-09-14 22:32:30 +0000 (Mon, 14 Sep 2009)
Log Message:
-----------
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: trunk/phase3/maintenance/backup.inc
===================================================================
--- trunk/phase3/maintenance/backup.inc 2009-09-14 22:11:46 UTC (rev 56346)
+++ trunk/phase3/maintenance/backup.inc 2009-09-14 22:32:30 UTC (rev 56347)
@@ -232,28 +232,26 @@
$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
+ $this->lb = wfGetLBFactory()->newMainLB();
+ $db = $this->lb->getConnection( DB_SLAVE, 'backup' );
- if ( !$wgDBadminuser ) {
- $wgDBadminuser = $wgDBuser;
- }
- if ( !$wgDBadminpassword ) {
- $wgDBadminpassword = $wgDBpassword;
- }
-
- $class = 'Database' . ucfirst($wgDBtype);
- $db = new $class( $this->backupServer(), $wgDBadminuser,
$wgDBadminpassword, $wgDBname, false, $flags );
-
// Discourage the server from disconnecting us if it takes a
long time
// to read out the big ol' batch query.
$db->setTimeout( 3600 * 24 );
return $db;
}
+
+ function __destruct() {
+ if( isset( $this->lb ) ) {
+ $this->lb->closeAll();
+ }
+ }
function backupServer() {
global $wgDBserver;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs