Problem/Motivation

The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityStorageException: Index main_en-gb does not exist in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (line 763 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper->request() (Line: 82)
Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper->read() (Line: 36)
Algolia\AlgoliaSearch\Iterators\ObjectIterator->fetchNextPage() (Line: 63)
Algolia\AlgoliaSearch\Iterators\AbstractAlgoliaIterator->__construct() (Line: 346)
Algolia\AlgoliaSearch\SearchIndex->browseObjects() (Line: 708)
Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend->deleteSplits() (Line: 450)
Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend->deleteItems() (Line: 456)
Drupal\search_api\Entity\Server->deleteItems() (Line: 1338)
Drupal\search_api\Entity\Index->trackItemsDeleted() (Line: 216)
Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager->entityDelete() (Line: 51)
Drupal\search_api\Hook\ContentEntityDatasourceHooks->entityDelete() (Line: 142)
search_api_entity_delete()
y-steps-reproduce">Steps to reproduce

use the language split setting
add a new language, but do not add any content for it, this means it's not initialized in algolia
try to delete content or reindex

- go to /admin/config/search/search-api/index/
- press queue all items for reindexing
- reindex
In this case (with reindexing), it's caught in a try catch statement, so it's not fatal, but with deleting content it's fatal.

Proposed resolution

check if index exists before trying to delete content from it.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

oknate created an issue. See original summary.

oknate’s picture

StatusFileSize
new1.28 KB

Here's a patch to fix it.

oknate’s picture

StatusFileSize
new1.47 KB

OK, in testing we need to test with index exists() function, not just that the object itself exists, here's an update.

davps’s picture

Version: 3.1.1 » 3.0.x-dev
Status: Active » Needs work

@oknate, good catch, thanks for reporting the issue. I checked and found that the problem affects all data deletion cases:

  • immediate content deletion (you described this case)
  • delayed content deletion (batch deletion via drush commands)
  • index deletion (it will attempt to delete data from all indexes, even from those that don't exist)

Thanks for the suggested solution, but it will need to be updated to cover other cases. It would be great to have tests for these cases.

davps’s picture

Version: 3.0.x-dev » 3.2.x-dev
oknate’s picture

Title: Indexes not initialized due to no content for the language cause errors when trying to delete content » Indexes not initialized due to no content for the language cause errors when trying to delete content or index.
Issue summary: View changes
oknate’s picture

Issue summary: View changes