Write load distribution across multiple external storage engines. Untested.
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 27 Mar 2006 03:56:53 +0000 (03:56 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 27 Mar 2006 03:56:53 +0000 (03:56 +0000)
includes/DefaultSettings.php
includes/Revision.php

index 43d0c57..7b0cd95 100644 (file)
@@ -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;
 
index d0eabfc..a89bb8b 100644 (file)
@@ -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 .= ',';