jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Smalyshev: Looks good to me, but someone else must approve
Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
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: merged
Gerrit-Change-Id: Icedc7c3e2a64682238648ca9ede657f6b39d612e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits