Problem/Motivation

You cannot use this module through the UI, because you get fatal errors when running "Execute tasks now" after configuring a new index.

Steps to reproduce

Configure a new OpensSearch server
Configure a new index and attach it to the server
Enable and add the index
Export the config
Change the prefix
Reinstall the site

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=7&op=do_nojs&op=do
StatusText: 500 Service unavailable (with message)
ResponseText: The website encountered an unexpected error. Please try again later.Drupal\search_api\SearchApiException: An error occurred creating the index commscontacts. in Drupal\search_api_opensearch\SearchAPI\BackendClient->addIndex() (line 248 of modules/contrib/search_api_opensearch/src/SearchAPI/BackendClient.php). OpenSearch\Connections\Connection->OpenSearch\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)
OpenSearch\Connections\Connection->OpenSearch\Connections\{closure}(Array, Object, Object, Array) (Line: 238)
OpenSearch\Connections\Connection->performRequest('PUT', '/commscontacts', Array, NULL, Array, Object) (Line: 113)
OpenSearch\Transport->performRequest('PUT', '/commscontacts', Array, NULL, Array) (Line: 66)
OpenSearch\Namespaces\AbstractNamespace->performRequest(Object) (Line: 172)
OpenSearch\Namespaces\IndicesNamespace->create(Array) (Line: 243)
Drupal\search_api_opensearch\SearchAPI\BackendClient->addIndex(Object) (Line: 392)
Drupal\search_api_opensearch\Plugin\search_api\backend\OpenSearchBackend->addIndex(Object) (Line: 145)
Drupal\search_api\Task\ServerTaskManager->executeTask(Object) (Line: 114)
Drupal\search_api\Task\ServerTaskManager->processEvent(Object, 'search_api.task.addIndex', Object)
call_user_func(Array, Object, 'search_api.task.addIndex', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, Object) (Line: 212)
Drupal\search_api\Task\TaskManager->executeSpecificTask(Object) (Line: 356)
Drupal\search_api\Task\TaskManager->processBatch(Array, Array, Array) (Line: 295)
_batch_process() (Line: 137)
_batch_do() (Line: 93)
_batch_page(Object) (Line: 55)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
CommentFileSizeAuthor
#9 3263986-9.patch517 bytesacbramley
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jessarexward created an issue. See original summary.

jessarexward’s picture

The error occurs in this function:

    public function resultOrFuture(FutureArrayInterface $result, array $options = [])
    {
        $response = null;
        $async = isset($options['client']['future']) ? $options['client']['future'] : null;
        if (is_null($async) || $async === false) {
          try {
            do {
              $result = $result->wait();
            }
            while ($result instanceof FutureArrayInterface);
          } catch (\Exception $e) {
            \Drupal::service('logger.factory')->get('ck_contacts')->debug($e->getMessage());
          }
        }
        return $result;
    }

When I add a try catch the following error messages are outputted:

{"error":{"root_cause":[@"type":"resource_already_exists_exception","reason":"index [commscontacts/AQU1L2KsT-eqBd8s5c4yFQ] already exists","index":"commscontacts","index_uuid":"AQU1L2KsT-eqBd8s5c4yFQ"],"type":"resource_already_exists_exception","reason":"index [commscontacts/AQU1L2KsT-eqBd8s5c4yFQ] already exists","index":"commscontacts","index_uuid":"AQU1L2KsT-eqBd8s5c4yFQ"},"status":400}
429 Too Many Requests /commscontacts/_search
jessarexward’s picture

Issue summary: View changes
jessarexward’s picture

Issue summary: View changes
jessarexward’s picture

It seems like when the site is installed with a preexisting index config, we are trying to add the index twice.

kim.pepper’s picture

Title: Another Fatal Error when running "Execute tasks now" » Uncaught exception when trying to create an index that already exists
Priority: Critical » Normal

Thanks for your bug report and trying out the alpha release.

I've re-titled this as it appears to be due to an uncaught exception when trying to create an index that already exists. We should be able to check if the index exists first and report an a more helpful error back to the user instead.

kim.pepper’s picture

Status: Active » Needs review

acbramley’s picture

StatusFileSize
new517 bytes

Patch with the above changes.

kim.pepper’s picture

Status: Needs review » Fixed

Committed and pushed to 1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.