[MediaWiki-commits] [Gerrit] Rewrite replica handling - change (mediawiki...CirrusSearch)
jenkins-bot has submitted this change and it was merged. Change subject: Rewrite replica handling .. Rewrite replica handling Use auto_expand_replicas. It's way nicer and easier to control. Change-Id: Ia707b3cabefab5ac5abf002017dc4d4c5f3fd078 --- M CirrusSearch.php M README M maintenance/checkIndexes.php M maintenance/updateOneSearchIndexConfig.php M maintenance/updateVersionIndex.php 5 files changed, 31 insertions(+), 40 deletions(-) Approvals: Manybubbles: Looks good to me, approved jenkins-bot: Verified diff --git a/CirrusSearch.php b/CirrusSearch.php index b1b3364..c9ced2a 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -45,11 +45,12 @@ // Number of shards for each index $wgCirrusSearchShardCount = array( 'content' => 4, 'general' => 4 ); -// Number of replicas per shard for each index -// The default of 0 is fine for single-node setups, but if this is -// deployed to a multi-node setting you probably at least want these -// set to 1 for some redundancy, if not 2 for more redundancy. -$wgCirrusSearchReplicaCount = array( 'content' => 0, 'general' => 0 ); +// Number of replicas Elasticsearch can expand or contract to. This allows for +// easy development and deployment to a single node (0 replicas) to scale up to +// higher levels of replication. You if you need more redundancy you could +// adjust this to '0-10' or '0-all' or even 'false' (string, not boolean) to +// disable the behavior entirely. The default should be fine for most people. +$wgCirrusSearchReplicas = '0-2'; // How many seconds must a search of Elasticsearch be before we consider it // slow? Default value is 10 seconds which should be fine for catching the rare @@ -80,8 +81,7 @@ // mapped to specific index suffixes. The keys are the namespace number, and // the value is a string name of what index suffix to use. Changing this setting // requires a full reindex (not in-place) of the wiki. If this setting contains -// any values then the index names must also exist in $wgCirrusSearchShardCount -// and $wgCirrusSearchReplicaCount. +// any values then the index names must also exist in $wgCirrusSearchShardCount. $wgCirrusSearchNamespaceMappings = array(); // Extra indexes (if any) you want to search, and for what namespaces? diff --git a/README b/README index af38c63..21d9ef5 100644 --- a/README +++ b/README @@ -17,8 +17,6 @@ Configure your search servers in LocalSettings.php if you aren't running Elasticsearch on localhost: $wgCirrusSearchServers = array( 'elasticsearch0', 'elasticsearch1', 'elasticsearch2', 'elasticsearch3' ); There are other $wgCirrusSearch variables that you might want to change from their defaults. -In production setups, you will very likely want to increase the number of replicas using -$wgCirrusSearchReplicaCount. Now run this script to generate your elasticsearch index: php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php @@ -198,15 +196,6 @@ # Disable ability to shutdown nodes via REST API. ## action.disable_shutdown: true - - -CirrusSearch - -You should change the number of replicas to at least one, two if you want protection from crashes -during upgrades. More replicas will help distribute queries across more nodes. Having more -replicas than nodes doesn't make sense and Elasticsearch will stay "yellow" if you do that. -Anyway, you should add this to LocalSettings.php to change it: - $wgCirrusSearchReplicaCount = array( 'content' => 2, 'general' => 2 ); Testing diff --git a/maintenance/checkIndexes.php b/maintenance/checkIndexes.php index 15739c4..d85df37 100644 --- a/maintenance/checkIndexes.php +++ b/maintenance/checkIndexes.php @@ -47,7 +47,7 @@ } $this->ensureClusterStateFetched(); $this->ensureCirrusInfoFetched(); - $this->checkIndex( 'mw_cirrus_versions', 1, 1 ); + $this->checkIndex( 'mw_cirrus_versions', 1 ); $aliases = array(); foreach ( $this->clusterState[ 'metadata' ][ 'indices' ] as $indexName => $data ) { foreach ( $data[ 'aliases' ] as $alias ) { @@ -56,7 +56,7 @@ } foreach ( $this->cirrusInfo as $alias => $data ) { foreach ( $aliases[ $alias ] as $indexName ) { - $this->checkIndex( $indexName, $data[ 'shard_count'], $data[ 'replica_count' ] ); + $this->checkIndex( $indexName, $data[ 'shard_count'] ); } } $indexCount = count( $this->cirrusInfo ); @@ -77,7 +77,7 @@ } } - private function checkIndex( $indexName, $expectedShardCount, $expectedReplicaCount ) { + private function checkIndex( $indexName, $expectedShardCount ) { $this->path = array(); $metdata = $thi
[MediaWiki-commits] [Gerrit] Rewrite replica handling - change (mediawiki...CirrusSearch)
Chad has uploaded a new change for review. https://gerrit.wikimedia.org/r/132463 Change subject: Rewrite replica handling .. Rewrite replica handling Use auto_expand_replicas. It's way nicer and easier to control. Change-Id: Ia707b3cabefab5ac5abf002017dc4d4c5f3fd078 --- M CirrusSearch.php M README M maintenance/checkIndexes.php M maintenance/updateOneSearchIndexConfig.php M maintenance/updateVersionIndex.php 5 files changed, 18 insertions(+), 38 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/63/132463/1 diff --git a/CirrusSearch.php b/CirrusSearch.php index b1b3364..c9ced2a 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -45,11 +45,12 @@ // Number of shards for each index $wgCirrusSearchShardCount = array( 'content' => 4, 'general' => 4 ); -// Number of replicas per shard for each index -// The default of 0 is fine for single-node setups, but if this is -// deployed to a multi-node setting you probably at least want these -// set to 1 for some redundancy, if not 2 for more redundancy. -$wgCirrusSearchReplicaCount = array( 'content' => 0, 'general' => 0 ); +// Number of replicas Elasticsearch can expand or contract to. This allows for +// easy development and deployment to a single node (0 replicas) to scale up to +// higher levels of replication. You if you need more redundancy you could +// adjust this to '0-10' or '0-all' or even 'false' (string, not boolean) to +// disable the behavior entirely. The default should be fine for most people. +$wgCirrusSearchReplicas = '0-2'; // How many seconds must a search of Elasticsearch be before we consider it // slow? Default value is 10 seconds which should be fine for catching the rare @@ -80,8 +81,7 @@ // mapped to specific index suffixes. The keys are the namespace number, and // the value is a string name of what index suffix to use. Changing this setting // requires a full reindex (not in-place) of the wiki. If this setting contains -// any values then the index names must also exist in $wgCirrusSearchShardCount -// and $wgCirrusSearchReplicaCount. +// any values then the index names must also exist in $wgCirrusSearchShardCount. $wgCirrusSearchNamespaceMappings = array(); // Extra indexes (if any) you want to search, and for what namespaces? diff --git a/README b/README index af38c63..21d9ef5 100644 --- a/README +++ b/README @@ -17,8 +17,6 @@ Configure your search servers in LocalSettings.php if you aren't running Elasticsearch on localhost: $wgCirrusSearchServers = array( 'elasticsearch0', 'elasticsearch1', 'elasticsearch2', 'elasticsearch3' ); There are other $wgCirrusSearch variables that you might want to change from their defaults. -In production setups, you will very likely want to increase the number of replicas using -$wgCirrusSearchReplicaCount. Now run this script to generate your elasticsearch index: php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php @@ -198,15 +196,6 @@ # Disable ability to shutdown nodes via REST API. ## action.disable_shutdown: true - - -CirrusSearch - -You should change the number of replicas to at least one, two if you want protection from crashes -during upgrades. More replicas will help distribute queries across more nodes. Having more -replicas than nodes doesn't make sense and Elasticsearch will stay "yellow" if you do that. -Anyway, you should add this to LocalSettings.php to change it: - $wgCirrusSearchReplicaCount = array( 'content' => 2, 'general' => 2 ); Testing diff --git a/maintenance/checkIndexes.php b/maintenance/checkIndexes.php index 15739c4..c4bbb65 100644 --- a/maintenance/checkIndexes.php +++ b/maintenance/checkIndexes.php @@ -56,7 +56,7 @@ } foreach ( $this->cirrusInfo as $alias => $data ) { foreach ( $aliases[ $alias ] as $indexName ) { - $this->checkIndex( $indexName, $data[ 'shard_count'], $data[ 'replica_count' ] ); + $this->checkIndex( $indexName, $data[ 'shard_count'] ); } } $indexCount = count( $this->cirrusInfo ); @@ -77,7 +77,7 @@ } } - private function checkIndex( $indexName, $expectedShardCount, $expectedReplicaCount ) { + private function checkIndex( $indexName, $expectedShardCount ) { $this->path = array(); $metdata = $this->getIndexMetadata( $indexName ); $this->in( $indexName ); @@ -92,7 +92,6 @@ $this->check( 'shard count', $expectedShardCount, count( $routingTable[ 'shards' ] ) ); foreach ( $routingTable[ 'shards' ] as $shardIndex => $shardRoutingTable ) { $this->in( "shard $shardIndex" ); - $this->check( 'replica count', $expectedRe