jenkins-bot has submitted this change and it was merged. Change subject: Add $wgCirrusSearchMasterTimeout to deal with master slowdowns ......................................................................
Add $wgCirrusSearchMasterTimeout to deal with master slowdowns We have had numerous issues over time with the cluster rejecting mapping updates because our master is too overloaded. It would be nice to fix the cluster, but this workaround will let us get on with our lives for now. Bug: T107348 Change-Id: I8178ea1a6b9776a93221ceaac98a8cd8ac399e8f --- M CirrusSearch.php M includes/Maintenance/Validators/MappingValidator.php M maintenance/updateOneSearchIndexConfig.php M maintenance/updateSuggesterIndex.php 4 files changed, 45 insertions(+), 4 deletions(-) Approvals: Smalyshev: Looks good to me, approved Cindy-the-browser-test-bot: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/CirrusSearch.php b/CirrusSearch.php index 49135ec..75968f3 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -827,6 +827,13 @@ */ $wgCirrusSearchLanguageDetectors = array(); +/** + * Overrides the master timeout on cluster wide actions, such as mapping updates. + * It may be necessary to increase this on clusters that support a large number + * of wiki's. + */ +$wgCirrusSearchMasterTimeout = '30s'; + $includes = __DIR__ . "/includes/"; $apiDir = $includes . 'Api/'; $buildDocument = $includes . 'BuildDocument/'; diff --git a/includes/Maintenance/Validators/MappingValidator.php b/includes/Maintenance/Validators/MappingValidator.php index 38c936c..752faf6 100644 --- a/includes/Maintenance/Validators/MappingValidator.php +++ b/includes/Maintenance/Validators/MappingValidator.php @@ -6,6 +6,7 @@ use CirrusSearch\Maintenance\Maintenance; use Elastica\Exception\ExceptionInterface; use Elastica\Index; +use Elastica\Request; use Elastica\Type; use Elastica\Type\Mapping; use RawMessage; @@ -16,6 +17,11 @@ * @var Index */ private $index; + + /** + * @var string + */ + private $masterTimeout; /** * @var bool @@ -41,16 +47,18 @@ * @todo: this constructor takes way too much arguments - refactor * * @param Index $index + * @param string $masterTimeout * @param bool $optimizeIndexForExperimentalHighlighter * @param array $availablePlugins * @param array $mappingConfig * @param Type[] $types Array with type names as key & type object as value * @param Maintenance $out */ - public function __construct( Index $index, $optimizeIndexForExperimentalHighlighter, array $availablePlugins, array $mappingConfig, array $types, Maintenance $out = null ) { + public function __construct( Index $index, $masterTimeout, $optimizeIndexForExperimentalHighlighter, array $availablePlugins, array $mappingConfig, array $types, Maintenance $out = null ) { parent::__construct( $out ); $this->index = $index; + $this->masterTimeout = $masterTimeout; $this->optimizeIndexForExperimentalHighlighter = $optimizeIndexForExperimentalHighlighter; $this->availablePlugins = $availablePlugins; $this->mappingConfig = $mappingConfig; @@ -86,8 +94,18 @@ } try { + // @todo Use $action->send(array('master_timeout' => ...)) + // after updating to version of Elastica library that supports it. + // See https://github.com/ruflin/Elastica/pull/1004 foreach ( $actions as $action ) { - $action->send(); + $action->getType()->request( + '_mapping', + Request::PUT, + $action->toArray(), + array( + 'master_timeout' => $this->masterTimeout, + ) + ); } $this->output( "corrected\n" ); } catch ( ExceptionInterface $e ) { diff --git a/maintenance/updateOneSearchIndexConfig.php b/maintenance/updateOneSearchIndexConfig.php index 9f23396..eea1c4d 100644 --- a/maintenance/updateOneSearchIndexConfig.php +++ b/maintenance/updateOneSearchIndexConfig.php @@ -115,6 +115,11 @@ */ protected $refreshInterval; + /** + * @var string + */ + protected $masterTimeout; + public function __construct() { parent::__construct(); $this->addDescription( "Update the configuration or contents of one search index. This always operates on a single cluster." ); @@ -173,7 +178,8 @@ $wgCirrusSearchBannedPlugins, $wgCirrusSearchOptimizeIndexForExperimentalHighlighter, $wgCirrusSearchMaxShardsPerNode, - $wgCirrusSearchRefreshInterval; + $wgCirrusSearchRefreshInterval, + $wgCirrusSearchMasterTimeout; // Make sure we don't flood the pool counter unset( $wgPoolCounterConf['CirrusSearch-Search'] ); @@ -198,6 +204,7 @@ $this->phraseSuggestUseText = $wgCirrusSearchPhraseSuggestUseText; $this->bannedPlugins = $wgCirrusSearchBannedPlugins; $this->optimizeIndexForExperimentalHighlighter = $wgCirrusSearchOptimizeIndexForExperimentalHighlighter; + $this->masterTimeout = $wgCirrusSearchMasterTimeout; $this->maxShardsPerNode = isset( $wgCirrusSearchMaxShardsPerNode[ $this->indexType ] ) ? $wgCirrusSearchMaxShardsPerNode[ $this->indexType ] : 'unlimited'; $this->refreshInterval = $wgCirrusSearchRefreshInterval; @@ -329,6 +336,7 @@ private function validateMapping() { $validator = new \CirrusSearch\Maintenance\Validators\MappingValidator( $this->getIndex(), + $this->masterTimeout, $this->optimizeIndexForExperimentalHighlighter, $this->availablePlugins, $this->getMappingConfig(), diff --git a/maintenance/updateSuggesterIndex.php b/maintenance/updateSuggesterIndex.php index 6bb2eb4..d5c0759 100644 --- a/maintenance/updateSuggesterIndex.php +++ b/maintenance/updateSuggesterIndex.php @@ -86,6 +86,11 @@ */ private $withGeo; + /** + * @var string + */ + private $masterTimeout; + public function __construct() { parent::__construct(); $this->addDescription( "Create a new suggester index. Always operates on a single cluster." ); @@ -109,8 +114,10 @@ global $wgLanguageCode, $wgCirrusSearchBannedPlugins, $wgCirrusSearchRefreshInterval, - $wgPoolCounterConf; + $wgPoolCounterConf, + $wgCirrusSearchMasterTimeout; + $this->masterTimeout = $wgCirrusSearchMasterTimeout; $this->indexTypeName = Connection::TITLE_SUGGEST_TYPE; // Make sure we don't flood the pool counter @@ -313,6 +320,7 @@ $mappingConfigBuilder = new SuggesterMappingConfigBuilder(); $validator = new \CirrusSearch\Maintenance\Validators\MappingValidator( $this->getIndex(), + $this->masterTimeout, false, $this->availablePlugins, $mappingConfigBuilder->buildConfig(), -- To view, visit https://gerrit.wikimedia.org/r/258017 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8178ea1a6b9776a93221ceaac98a8cd8ac399e8f Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Cindy-the-browser-test-bot <bernhardsone...@gmail.com> Gerrit-Reviewer: DCausse <dcau...@wikimedia.org> Gerrit-Reviewer: Manybubbles <never...@wikimedia.org> Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits