jenkins-bot has submitted this change and it was merged.

Change subject: Better handle PoolErrors.
......................................................................


Better handle PoolErrors.

This should stop those sometimes crashes during rebuilds.

Bug: 56060
Change-Id: I6f293c6cf3470e8c85339f30b99776cbe5d31021
---
M includes/CirrusSearchSearcher.php
M includes/CirrusSearchUpdater.php
2 files changed, 27 insertions(+), 7 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/CirrusSearchSearcher.php 
b/includes/CirrusSearchSearcher.php
index 3fceed2..573a2b6 100644
--- a/includes/CirrusSearchSearcher.php
+++ b/includes/CirrusSearchSearcher.php
@@ -283,10 +283,15 @@
                                        return Status::newGood( null );
                                } catch ( 
\Elastica\Exception\ExceptionInterface $e ) {
                                        wfLogWarning( "Search backend error 
during get for $id.  Error message is:  " . $e->getMessage() );
-                                       $status = new Status();
-                                       $status->warning( 
'cirrussearch-backend-error' );
-                                       return $status;
+                                       return Status::newFatal( 
'cirrussearch-backend-error' );
                                }
+                       },
+                       'error' => function( $status ) {
+                               $status = $status->getErrorsArray();
+                               wfLogWarning( 'Pool error performing a get 
against Elasticsearch:  ' . $status[ 0 ][ 0 ] );
+                               // We return a Status here because the get 
method actually supports returning a Status.  Other methods
+                               // should support this but don't yet.
+                               return $status;
                        }
                ) );
                $result = $getWork->execute();
@@ -362,6 +367,11 @@
                                        wfLogWarning( "Search backend error 
during $description.  Error message is:  " . $e->getMessage() );
                                        return false;
                                }
+                       },
+                       'error' => function( $status ) {
+                               $status = $status->getErrorsArray();
+                               wfLogWarning( 'Pool error searching 
Elasticsearch:  ' . $status[ 0 ][ 0 ] );
+                               return false;
                        }
                ) );
                $result = $work->execute();
diff --git a/includes/CirrusSearchUpdater.php b/includes/CirrusSearchUpdater.php
index cca0db8..c78fcd5 100644
--- a/includes/CirrusSearchUpdater.php
+++ b/includes/CirrusSearchUpdater.php
@@ -180,14 +180,19 @@
                        return;
                }
                wfDebugLog( 'CirrusSearch', "Sending $documentCount documents 
to the $indexType index." );
-               $work = new PoolCounterWorkViaCallback( 'CirrusSearch-Update', 
"_elasticsearch",
-                       array( 'doWork' => function() use ( $indexType, 
$documents ) {
+               $work = new PoolCounterWorkViaCallback( 'CirrusSearch-Update', 
"_elasticsearch", array(
+                       'doWork' => function() use ( $indexType, $documents ) {
                                try {
                                        $result = 
CirrusSearchConnection::getPageType( $indexType )->addDocuments( $documents );
                                        wfDebugLog( 'CirrusSearch', 'Update 
completed in ' . $result->getEngineTime() . ' (engine) millis' );
                                } catch ( 
\Elastica\Exception\ExceptionInterface $e ) {
                                        error_log( "CirrusSearch update failed 
caused by:  " . $e->getMessage() );
                                }
+                       },
+                       'error' => function( $status ) {
+                               $status = $status->getErrorsArray();
+                               wfLogWarning( 'Pool error sending documents to 
Elasticsearch:  ' . $status[ 0 ][ 0 ] );
+                               return false;
                        }
                ) );
                $work->execute();
@@ -403,14 +408,19 @@
                        return;
                }
                wfDebugLog( 'CirrusSearch', "Sending $idCount deletes to the 
$indexType index." );
-               $work = new PoolCounterWorkViaCallback( 'CirrusSearch-Update', 
"_elasticsearch",
-                       array( 'doWork' => function() use ( $indexType, $ids ) {
+               $work = new PoolCounterWorkViaCallback( 'CirrusSearch-Update', 
"_elasticsearch", array(
+                       'doWork' => function() use ( $indexType, $ids ) {
                                try {
                                        $result = 
CirrusSearchConnection::getPageType( $indexType )->deleteIds( $ids );
                                        wfDebugLog( 'CirrusSearch', 'Delete 
completed in ' . $result->getEngineTime() . ' (engine) millis' );
                                } catch ( 
\Elastica\Exception\ExceptionInterface $e ) {
                                        error_log( "CirrusSearch delete failed 
caused by:  " . $e->getMessage() );
                                }
+                       },
+                       'error' => function( $status ) {
+                               $status = $status->getErrorsArray();
+                               wfLogWarning( 'Pool error sending deletes to 
Elasticsearch:  ' . $status[ 0 ][ 0 ] );
+                               return false;
                        }
                ) );
                $work->execute();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6f293c6cf3470e8c85339f30b99776cbe5d31021
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to