EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/258088
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 (cherry picked from commit bd7c6dae7a4a15b8bf91fe319d1297b6802b733c) --- M CirrusSearch.php M includes/Maintenance/Validators/MappingValidator.php M maintenance/updateOneSearchIndexConfig.php M maintenance/updateSuggesterIndex.php 4 files changed, 45 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/88/258088/1 diff --git a/CirrusSearch.php b/CirrusSearch.php index df60fbb..ecb44c6 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -804,6 +804,13 @@ */ $wgCirrusSearchInterwikiThreshold = 3; +/** + * 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 5544d3d..ceeef2c 100644 --- a/maintenance/updateOneSearchIndexConfig.php +++ b/maintenance/updateOneSearchIndexConfig.php @@ -116,6 +116,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." ); @@ -174,7 +179,8 @@ $wgCirrusSearchBannedPlugins, $wgCirrusSearchOptimizeIndexForExperimentalHighlighter, $wgCirrusSearchMaxShardsPerNode, - $wgCirrusSearchRefreshInterval; + $wgCirrusSearchRefreshInterval, + $wgCirrusSearchMasterTimeout; // Make sure we don't flood the pool counter unset( $wgPoolCounterConf['CirrusSearch-Search'] ); @@ -199,6 +205,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; @@ -330,6 +337,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/258088 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8178ea1a6b9776a93221ceaac98a8cd8ac399e8f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: wmf/1.27.0-wmf.7 Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits