From: Tim Starling Date: Mon, 27 Mar 2006 03:56:53 +0000 (+0000) Subject: Write load distribution across multiple external storage engines. Untested. X-Git-Tag: 1.6.0~113 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=feee1cc43df6c60dfaf447b4d0df2bee2a7a91dd;p=lhc%2Fweb%2Fwiklou.git Write load distribution across multiple external storage engines. Untested. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 43d0c57f04..7b0cd9522c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1821,6 +1821,12 @@ $wgExternalServers = array(); /** * The place to put new revisions, false to put them in the local text table. * Part of a URL, e.g. DB://cluster1 + * + * Can be an array instead of a single string, to enable data distribution. Keys + * must be consecutive integers, starting at zero. Example: + * + * $wgDefaultExternalStore = array( 'DB://cluster1', 'DB://cluster2' ); + * */ $wgDefaultExternalStore = false; diff --git a/includes/Revision.php b/includes/Revision.php index d0eabfc2b5..a89bb8ba13 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -593,12 +593,18 @@ class Revision { # Write to external storage if required if ( $wgDefaultExternalStore ) { + if ( is_array( $wgDefaultExternalStore ) ) { + // Distribute storage across multiple clusters + $store = $wgDefaultExternalStore[mt_rand(0, count( $wgDefaultExternalStore ) - 1)]; + } else { + $store = $wgDefaultExternalStore; + } require_once('ExternalStore.php'); // Store and get the URL - $data = ExternalStore::insert( $wgDefaultExternalStore, $data ); + $data = ExternalStore::insert( $store, $data ); if ( !$data ) { # This should only happen in the case of a configuration error, where the external store is not valid - wfDebugDieBacktrace( "Unable to store text to external storage $wgDefaultExternalStore" ); + wfDebugDieBacktrace( "Unable to store text to external storage $store" ); } if ( $flags ) { $flags .= ',';