DCausse has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/259683

Change subject: Do not build the suggester index if the cluster is frozen.
......................................................................

Do not build the suggester index if the cluster is frozen.

Change-Id: Icedc7c3e2a64682238648ca9ede657f6b39d612e
---
M maintenance/updateSuggesterIndex.php
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/83/259683/1

diff --git a/maintenance/updateSuggesterIndex.php 
b/maintenance/updateSuggesterIndex.php
index c36aa24..55a2d4d 100644
--- a/maintenance/updateSuggesterIndex.php
+++ b/maintenance/updateSuggesterIndex.php
@@ -3,6 +3,7 @@
 namespace CirrusSearch\Maintenance;
 
 use CirrusSearch\Connection;
+use CirrusSearch\DataSender;
 use CirrusSearch\ElasticsearchIntermediary;
 use CirrusSearch\Util;
 use CirrusSearch\BuildDocument\SuggestBuilder;
@@ -169,6 +170,9 @@
                $this->refreshInterval = $wgCirrusSearchRefreshInterval;
 
                try {
+                       if ( !$this->canWrite() ) {
+                               $this->error( 'Index/Cluster is frozen. Giving 
up.', 1 );
+                       }
                        $oldIndexIdentifier = 
$this->utils->pickIndexIdentifierFromOption( 'current', 
$this->getIndexTypeName() );
                        $this->oldIndex = $this->getConnection()->getIndex( 
$this->indexBaseName, $this->indexTypeName, $oldIndexIdentifier );
                        $this->indexIdentifier = 
$this->utils->pickIndexIdentifierFromOption( 'now', $this->getIndexTypeName() );
@@ -203,6 +207,18 @@
                $this->getIndex()->refresh();
        }
 
+       /**
+        * Check the frozen indices
+        * @return true if the cluster/index is not frozen, false otherwise.
+        */
+       private function canWrite() {
+               $name = $this->getConnection()->getIndexName( 
$this->indexBaseName, Connection::TITLE_SUGGEST_TYPE_NAME );
+               // Reuse DataSender even if we don't send anything with it.
+               $sender = new DataSender( $this->getConnection() );
+               return $sender->areIndexesAvailableForWrites( array( $name ) );
+       }
+
+
        private function deleteOldIndex() {
                if ( $this->oldIndex && $this->oldIndex->exists() ) {
                        $this->output("Deleting " . $this->oldIndex->getName() 
. " ... ");

-- 
To view, visit https://gerrit.wikimedia.org/r/259683
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icedc7c3e2a64682238648ca9ede657f6b39d612e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to