Manybubbles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86974
Change subject: More efficient alias maintenance.
......................................................................
More efficient alias maintenance.
Elastica's method to fetch which index has an alias is very slow. We
work around it and see a significant speed improvement on clusters with
lots of indecies.
Bug: 54505
Change-Id: Iaa25accfb6c83f36455bf15af66c08233dcdd31c
---
M updateOneSearchIndexConfig.php
1 file changed, 22 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/74/86974/1
diff --git a/updateOneSearchIndexConfig.php b/updateOneSearchIndexConfig.php
index 8a23fd5..978e3aa 100644
--- a/updateOneSearchIndexConfig.php
+++ b/updateOneSearchIndexConfig.php
@@ -266,8 +266,7 @@
private function validateSpecificAlias() {
$this->output( $this->indent . "\tValidating $this->indexType
alias..." );
$otherIndeciesWithAlias = array();
- foreach (
CirrusSearchConnection::getClient()->getStatus()->getIndicesWithAlias(
- $this->getIndexTypeName() ) as $index ) {
+ foreach ( $this->getIndicesWithAlias( $this->getIndexTypeName()
) as $index ) {
if( $index->getName() === $this->getSpecificIndexName()
) {
$this->output( "ok\n" );
return;
@@ -307,8 +306,7 @@
public function validateAllAlias() {
$this->output( $this->indent . "\tValidating all alias..." );
$allAliasName = CirrusSearchConnection::getIndexName();
- foreach ( CirrusSearchConnection::getClient()->getStatus()
- ->getIndicesWithAlias( $allAliasName ) as
$index ) {
+ foreach ( $this->getIndicesWithAlias( $allAliasName ) as $index
) {
if( $index->getName() === $this->getSpecificIndexName()
) {
$this->output( "ok\n" );
return;
@@ -499,6 +497,26 @@
global $wgCirrusSearchContentReplicaCount;
return $wgCirrusSearchContentReplicaCount[ $this->indexType ];
}
+
+ /**
+ * Get indecies with the named alias. Doesn't use Elastica's
status->getIndicesWithAlias because
+ * that feches index status from _every_ index.
+ *
+ * @var $alias string alias name
+ * @return array(\Elastica\Index) of index names
+ */
+ private function getIndicesWithAlias( $alias ) {
+ $client = CirrusSearchConnection::getClient();
+ $response = $client->request( "/_alias/$alias" );
+ if ( $response->hasError() ) {
+ $this->error( 'Error fetching indecies with alias: ' .
$response->getError() );
+ }
+ $result = array();
+ foreach ( $response->getData() as $name => $info ) {
+ $result[] = new \Elastica\Index($client, $name);
+ }
+ return $result;
+ }
}
$maintClass = "UpdateOneSearchIndexConfig";
--
To view, visit https://gerrit.wikimedia.org/r/86974
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa25accfb6c83f36455bf15af66c08233dcdd31c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits