Execute Pending Tasks blocks indexing

Created on 20 March 2025, 16 days ago

Problem/Motivation

I occasionally run into this issue where indexing stops working and I notice that "Execute Pending Tasks" is on the main server overview page. Nothing works until I manually truncate the search_api_tasks table. If I try and index via drush I get a "Segmentation Fault". The only other reference I've found to this issue is this:

So it is possible to change field mappings if you clear the index and re-index everything. The issue is that once you change a field mapping search_api adds a new task to the DB to update that mapping. Doing any other action on the index tries to execute that task first which results in an exception and doesn't delete the task. It means that it's impossible to clear the index after changing a field's type. The only workaround currently is to manually delete all tasks (e.g delete from search_api_task;) and then clear the index. After doing that you're able to index again with the new field mapping.

I wonder if we can simply hook into the updateMapping process and re-create the index first?

That's from this issue: https://www.drupal.org/project/search_api_opensearch/issues/3266032#comm... 🐛 Cannot change field mapping Fixed

Steps to reproduce

I don't think we changed a field mapping, but a processor was added so maybe that can do it too.

Proposed resolution

Not sure. Currently working around it with manual truncation.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

achap 🇦🇺

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

Comments & Activities

  • Issue created by @achap
  • achap 🇦🇺

    For more context, this error is in the logs: OpenSearch\Exception\ForbiddenHttpException: [] in OpenSearch\Exception\HttpExceptionFactory::create() (line 25 of /app/vendor/opensearch-project/opensearch-php/src/OpenSearch/Exception/HttpExceptionFactory.php).

    However, once truncating the table I can index fine so I don't think it is an authentication issue.

  • achap 🇦🇺

    Ok so I was able to dig a bit deeper into it and the error I posted above in #2 is not related so can be ignored. I stepped through with my debugger after clicking "Execute Pending Tasks" and in updateIndex it is calling clear because there are some differences between the opensearch mappings and the drupal mappings, however what appears to be happening is deleting the index is causing search api to dispatch the updateIndex event again before it actually deletes the index, but because we haven't actually cleared the opensearch index the mappings are actually still different, so it's causing a redirect loop where deleting just continually calls updateIndex. I've posted some screenshots from my debugger.

    Stack trace showing the redirect loop:

    For some reason search api is executing all those tasks:

Production build 0.71.5 2024