Configure LoadBalancer with $wgSharedTables after WAN cache autodetection
authorMáté Szabó <mszabo@wikia-inc.com>
Wed, 22 May 2019 16:03:50 +0000 (18:03 +0200)
committerMáté Szabó <mszabo@wikia-inc.com>
Wed, 22 May 2019 16:03:50 +0000 (18:03 +0200)
Currently, $wgSharedTables - if configured - is injected into the LoadBalancer
before the WAN cache autodetection runs. As such, if $wgSharedTables is set
but $wgMainWANCache was not explicitly given, the LoadBalancer will force
a premature instantion of the WAN cache with an EmptyBagOStuff backend,
preventing the autodetection logic from setting a correct backend.
This change moves $wgSharedTables initialization after the WAN cache
autodetection to accunt for this scenario.

Change-Id: I59bb52f42905cda1c2aa47bc589a2f0b36b2a28f

includes/Setup.php

index 071b7c6..a51cb83 100644 (file)
@@ -605,20 +605,6 @@ if ( $wgDebugToolbar && !$wgCommandLineMode ) {
 // re-created while taking into account any custom settings and extensions.
 MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
 
 // re-created while taking into account any custom settings and extensions.
 MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
 
-if ( $wgSharedDB && $wgSharedTables ) {
-       // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
-       MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
-               array_fill_keys(
-                       $wgSharedTables,
-                       [
-                               'dbname' => $wgSharedDB,
-                               'schema' => $wgSharedSchema,
-                               'prefix' => $wgSharedPrefix
-                       ]
-               )
-       );
-}
-
 // Define a constant that indicates that the bootstrapping of the service locator
 // is complete.
 define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
 // Define a constant that indicates that the bootstrapping of the service locator
 // is complete.
 define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
@@ -694,6 +680,20 @@ if ( $wgMainWANCache === false ) {
        ];
 }
 
        ];
 }
 
+if ( $wgSharedDB && $wgSharedTables ) {
+       // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
+       MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
+               array_fill_keys(
+                       $wgSharedTables,
+                       [
+                               'dbname' => $wgSharedDB,
+                               'schema' => $wgSharedSchema,
+                               'prefix' => $wgSharedPrefix
+                       ]
+               )
+       );
+}
+
 Profiler::instance()->scopedProfileOut( $ps_default2 );
 
 $ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );
 Profiler::instance()->scopedProfileOut( $ps_default2 );
 
 $ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );