From 420c0e0f42509be4b404c74efeb6f77e93bf9599 Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Wed, 22 May 2019 18:03:50 +0200 Subject: [PATCH] Configure LoadBalancer with $wgSharedTables after WAN cache autodetection 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/includes/Setup.php b/includes/Setup.php index 071b7c6feb..a51cb83c19 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -605,20 +605,6 @@ if ( $wgDebugToolbar && !$wgCommandLineMode ) { // 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 ); @@ -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' ); -- 2.20.1