From 22aa68fe1d053ed038ee42129a90930e3973e741 Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 6 Dec 2024 22:06:12 +0000 Subject: [PATCH] Set LoadMonitor (#5759) It appears that this is the default here https://github.com/wikimedia/mediawiki/blob/4bd27f449569c211f6e74fa48e4e6ed6506d4a27/includes/libs/rdbms/lbfactory/LBFactoryMulti.php#L159 But we want to set maxConnCount I think, as some times we have an issue where a db server goes down it gets overloaded when it is back online. It's basically the same fix as https://phabricator.wikimedia.org/T360930 --------- Co-authored-by: github-actions --- Database.php | 5 ++++- LocalWiki.php | 6 +++--- rpc/RunJobs.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Database.php b/Database.php index bb96507296..23dca3039b 100644 --- a/Database.php +++ b/Database.php @@ -96,11 +96,14 @@ ]; } +$wgLBFactoryConf['loadMonitor']['class'] = '\Wikimedia\Rdbms\LoadMonitor'; // Disable LoadMonitor in CLI, it doesn't provide much value in CLI. if ( PHP_SAPI === 'cli' ) { - $wgLBFactoryConf['loadMonitorClass'] = \Wikimedia\Rdbms\LoadMonitorNull::class; + $wgLBFactoryConf['loadMonitor']['class'] = '\Wikimedia\Rdbms\LoadMonitorNull'; } +$wgLBFactoryConf['loadMonitor']['maxConnCount'] = 350; + // Disallow web request database transactions that are slower than 10 seconds $wgMaxUserDBWriteDuration = 10; diff --git a/LocalWiki.php b/LocalWiki.php index 634bec6324..b18dad3fb6 100644 --- a/LocalWiki.php +++ b/LocalWiki.php @@ -697,13 +697,13 @@ function onBeforePageDisplay( OutputPage $out ) { break; case 'testwikibeta': - $wgUserLevels = array( + $wgUserLevels = [ 'Recruit' => 0, 'Apprentice' => 1200, 'Private' => 1750, 'Corporal' => 2500, 'Sergeant' => 5000, - 'Gunnery Sergeant' =>10000, + 'Gunnery Sergeant' => 10000, 'Lieutenant' => 20000, 'Captain' => 35000, 'Major' => 50000, @@ -716,7 +716,7 @@ function onBeforePageDisplay( OutputPage $out ) { 'Lieutenant General' => 650000, 'General' => 800000, 'General of the Army' => 1000000, - ); + ]; break; case 'tuscriaturaswiki': $wgHooks['AfterFinalPageOutput'][] = 'onAfterFinalPageOutput'; diff --git a/rpc/RunJobs.php b/rpc/RunJobs.php index 131639e308..77a0b6cc16 100644 --- a/rpc/RunJobs.php +++ b/rpc/RunJobs.php @@ -24,7 +24,7 @@ use MediaWiki\MediaWikiServices; -if ( !in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '0:0:0:0:0:0:0:1', '::1' ), true ) ) { +if ( !in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '0:0:0:0:0:0:0:1', '::1' ], true ) ) { http_response_code( 500 ); die( "Only loopback requests are allowed.\n" ); } elseif ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {