jenkins-bot has submitted this change and it was merged.
Change subject: Switch shard startup monitoring using health api
......................................................................
Switch shard startup monitoring using health api
and add useful logging during the process.
Bug: 57247
Change-Id: I1864bb00265ce257781cd183f13873b2d147b6a7
---
M maintenance/updateOneSearchIndexConfig.php
1 file changed, 19 insertions(+), 20 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/maintenance/updateOneSearchIndexConfig.php
b/maintenance/updateOneSearchIndexConfig.php
index ab90e8a..19d75a9 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -369,14 +369,28 @@
$this->output( "Done\n" );
$this->validateIndexSettings();
$this->output( $this->indent . "\tWaiting for
all shards to start...\n" );
+ $expectedActive = $this->getShardCount() * ( 1
+ $this->getReplicaCount() );
+ $indexName = $this->getSpecificIndexName();
+ $path = "_cluster/health/$indexName";
$each = 0;
while ( true ) {
- $unstarted =
$this->indexShardsUnstarted();
- if ( $each === 0 ) {
- $this->output( $this->indent .
"\t\t$unstarted remaining\n" );
+ $response =
CirrusSearchConnection::getClient()->request( $path );
+ if ( $response->hasError() ) {
+ $this->error( 'Error fetching
index health but going to retry. Message: ' + $response->getError() );
+ sleep( 1 );
+ continue;
}
- if ( $unstarted === 0 ) {
- break;
+ $health = $response->getData();
+ $active = $health[ 'active_shards' ];
+ $relocating = $health[
'relocating_shards' ];
+ $initializing = $health[
'initializing_shards' ];
+ $unassigned = $health[
'unassigned_shards' ];
+ if ( $each === 0 || $active ===
$expectedActive ) {
+ $this->output( $this->indent .
"\t\tactive:$active/$expectedActive relocating:$relocating " .
+
"initializing:$initializing unassigned:$unassigned\n" );
+ if ( $active ===
$expectedActive ) {
+ break;
+ }
}
$each = ( $each + 1 ) % 20;
sleep( 1 );
@@ -395,21 +409,6 @@
"--reindexAndRemoveOk. Make sure you understand the
consequences of either\n" .
"choice." );
$this->returnCode = 1;
- }
-
- private function indexShardsUnstarted() {
- $data = $this->getIndex()->getStatus()->getData();
- $count = 0;
- foreach ( $data[ 'indices' ] as $index ) {
- foreach ( $index[ 'shards' ] as $shard ) {
- foreach ( $shard as $replica ) {
- if ( $replica[ 'state' ] !== 'STARTED'
) {
- $count++;
- }
- }
- }
- }
- return $count;
}
public function validateAllAlias() {
--
To view, visit https://gerrit.wikimedia.org/r/96366
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1864bb00265ce257781cd183f13873b2d147b6a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits