Search API list tag does not get purged

Created on 24 October 2018, about 6 years ago
Updated 8 February 2024, 10 months ago

Problem/Motivation

The Search API module has a special cache tag that gets invalidated when when search index is updated. The invalidation is detected by Purge, but the tag does not end up in the purge queue. This tag can be used to invalidate views build on search index results.

To reproduce:
- Set up Search API with a server and one index. We use it in combination with Seach API Solr, but this is probably not relevant.
- Create a view based on a Search API index. Set the view caching to Search API tag based caching.
- Edit a node that is listed by the view, or create a new node that gets listed.
- Check that the Search API tag (format: search_api_list:{search index name}) is added/increased in the cachetags table.
- See that this tag is not added in the purge_queue table. The node_list tag is added.

Methods called when search_api_list tag is invalidated:

  • \Drupal\search_api\Entity\Index::indexSpecificItems (this is where the search_api_list tag is invalidated)
  • \Drupal\purge_queuer_coretags\CacheTagsQueuer::invalidateTags
  • \Drupal\purge\Plugin\Purge\Queue\QueueService::add (last method called in Purge related to this tag)

The methods called when other tags (e.g. node_list) are invalidated.

  • \Drupal\purge\Plugin\Purge\Queue\QueueService::add
  • \Drupal\purge\Plugin\Purge\Queue\QueueService::commit
  • \Drupal\purge\Plugin\Purge\Queue\QueueService::commitAdding
  • \Drupal\purge\Plugin\Purge\Queue\QueueService::commitReleasing

The reason that QueueService::commit is not called after Index::indexSpecificItems, is because both are executed during the service destruction phase. In \Drupal\Core\EventSubscriber\KernelDestructionSubscriber::onKernelTerminate the following services are due for desctruction in the given order. Note that search_api.post_request_indexing is called after purge.queue.
The service destruction itself has no priority per service. I tried increasing the purge module's weight to 10, but that did solve the destruction order, but still the tag is not added to the purge_queue table.
Also tried to change the pruge services destruct priority ({ name: needs_destruction, priority: -100 }) but without success. This seems to have no effect on the destruction order.

Initial destruction order (purge module weight = 0):

β€Œarray (
  0 => 'state',
  1 => 'path.alias_whitelist',
  2 => 'menu.active_trail',
  3 => 'theme.registry',
  4 => 'library.discovery.collector',
  5 => 'block_content.uuid_lookup',
  6 => 'string_translator.locale.lookup',
  7 => 'purge.logger',
  8 => 'purge.queue',
  9 => 'purge.queue.stats',
  10 => 'purge.purgers.tracker.runtime_measurement',
  11 => 'search_api.post_request_indexing',
  12 => 'drupal.proxy_original_service.router.builder',
)

Proposed resolution

t.b.d.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands sutharsan

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