entity.search_api_index.canonical rouote will produce fatal error when backend is down

Created on 10 December 2020, over 4 years ago
Updated 30 August 2024, 8 months ago

Problem/Motivation

If search backend dies, route entity.search_api_index.canonical will throw fatal error. This is because $index->status() assumes the backend is up-and-running.

Steps to reproduce

1. Create server and index.
2. Shut down search backend, e.g. sudo service elasticsearch stop
3. Go to /admin/config/search/search-api/index/{index_name}

Fatal error is produced.

The website encountered an unexpected error. Please try again later.

Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster in Elasticsearch\ConnectionPool\StaticNoPingConnectionPool->nextConnection() (line 64 of /var/www/html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php).
Elasticsearch\Transport->getConnection() (Line: 99)
Elasticsearch\Transport->performRequest('HEAD', '/my_test_index', Array, NULL, Array) (Line: 292)
Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) (Line: 28)
React\Promise\FulfilledPromise->then(Object, NULL, NULL) (Line: 55)
GuzzleHttp\Ring\Future\CompletedFutureValue->then(Object, NULL, NULL) (Line: 341)
GuzzleHttp\Ring\Core::proxy(Object, Object) (Line: 340)
Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array, Object, Object, Array) (Line: 236)
Elasticsearch\Connections\Connection->performRequest('HEAD', '/my_test_index', Array, NULL, Array, Object) (Line: 110)
Elasticsearch\Transport->performRequest('HEAD', '/my_test_index', Array, NULL, Array) (Line: 43)
Elasticsearch\Namespaces\BooleanRequestWrapper::performRequest(Object, Object) (Line: 292)
Elasticsearch\Namespaces\IndicesNamespace->exists(Array) (Line: 615)
Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend->search(Object) (Line: 468)
Drupal\search_api\Entity\Server->search(Object) (Line: 539)
Drupal\search_api\Query\Query->execute() (Line: 311)
template_preprocess_search_api_index(Array, 'search_api_index', Array) (Line: 305)

Proposed resolution

Check if server is available on template_preprocess_search_api_index()

Remaining tasks

🐛 Bug report
Status

Needs review

Version

7.0

Component

Code

Created by

🇫🇮Finland sokru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024